PHP MiniProject-report
PHP MiniProject-report
A Micro-Project Proposal
1
2
Annexure - II
Micro-Project Report
1.0 Rationale:
This car registration micro project addresses the need for a well-organized and centralized
system for managing car details. Manually tracking car data can be cumbersome and prone to
errors.
This project offers a user-friendly web interface to streamline car registration, data storage,
and retrieval. By storing information in a central database, the project ensures data accuracy
and facilitates easy access for viewing, editing, and deleting car records.
The system also presents data in a clear and organized table format, enabling efficient
browsing and analysis. This micro project ultimately aims to improve decision-making by
providing readily available and organized car information.
3
✓ Advantages:
✓ Rules:
i. Data Validation:
Ensure that all input data is validated to prevent errors and protect the integrity of the
database.
v. Regulatory Compliance:
Adhere to relevant regulations and guidelines governing data privacy and security,
particularly concerning the handling of personal information.
4
5.0 Actual Resources Used:
“conn.php”
<?php
$hostname="localhost";
$username="root";
$password="";
$database="cars-register";
$conn=mysqli_connect($hostname,$username,$password,$database);
if(!$conn)
{
die("connection failed");
}
?>
“register_car.php”
<?php
session_start();
require 'conn.php';
if(isset($_POST['submit']))
{
$_SESSION['model'] = $_POST['name'];
$_SESSION['brand'] = $_POST['brand'];
$_SESSION['engine'] = $_POST['engine'];
$_SESSION['hp'] = $_POST['hp'];
$_SESSION['torque'] = $_POST['torque'];
$_SESSION['cc'] = $_POST['cc'];
$_SESSION['speed'] = $_POST['speed'];
$_SESSION['acceleration'] = $_POST['acceleration'];
$_SESSION['fuel'] = $_POST['fuel'];
$_SESSION['drive'] = $_POST['drive'];
$_SESSION['transmission'] = $_POST['transmission'];
$_SESSION['cylinder'] = $_POST['cylinder'];
$_SESSION['CarWeight'] = $_POST['weight'];
5
$_SESSION['price'] = $_POST['price'];
if(isset($_POST['submit']))
{
$model = $_POST['name'];
$brand = $_POST['brand'];
$engine = $_POST['engine'];
$hp = $_POST['hp'];
$torque = $_POST['torque'];
$cc = $_POST['cc'];
$speed = $_POST['speed'];
$acceleration = $_POST['acceleration'];
$fuel = $_POST['fuel'];
$drive = $_POST['drive'];
$transmission = $_POST['transmission'];
$cylinder = $_POST['cylinder'];
$CarWeight = $_POST['weight'];
$price = $_POST['price'];
if(mysqli_query($conn,$sql))
{
6
echo "<script>if(confirm('Data inserted successfully. If you want to add one more record. Click
OK.')){location.assign('register_car.php');}else{location.assign('display.php');}</script>";
}
else
{
echo "<script>alert('Data is not inserted!');</script>";
}
}
?>
<html>
<head>
<meta charset="utf-8">
<title>Add your car</title>
<link rel="stylesheet" type="text/css" href="css/register-car.css">
</head>
<body>
if(isset($_COOKIE['countvisit']))
{
$countvisit = $_COOKIE['countvisit'];
$countvisit ++;
}
setcookie('countvisit', $countvisit);
echo '<script>alert("You have visited '.$countvisit.' times");</script>';
?>
<div class="login-root">
<div class="box-root flex-flex flex-direction--column" style="min-height: 100vh;flex-grow: 1;">
<div class="loginbackground box-background--white padding-top--64">
<div class="loginbackground-gridContainer">
<div class="box-root flex-flex" style="grid-area: top / start / 8 / end;">
<div class="box-root" style="background-image: linear-gradient(white 0%, rgb(247, 250, 252)
33%); flex-grow: 1;">
</div>
</div>
<div class="box-root flex-flex" style="grid-area: 4 / 2 / auto / 5;">
7
<div class="box-root box-divider--light-all-2 animationLeftRight tans3s" style="flex-grow:
1;"></div>
</div>
<div class="box-root flex-flex" style="grid-area: 6 / start / auto / 2;">
<div class="box-root box-background--blue800" style="flex-grow: 1;"></div>
</div>
<div class="box-root flex-flex" style="grid-area: 7 / start / auto / 4;">
<div class="box-root box-background--blue animationLeftRight" style="flex-grow: 1;"></div>
</div>
<div class="box-root flex-flex" style="grid-area: 8 / 4 / auto / 6;">
<div class="box-root box-background--gray100 animationLeftRight tans3s" style="flex-grow:
1;"></div>
</div>
<div class="box-root flex-flex" style="grid-area: 2 / 15 / auto / end;">
<div class="box-root box-background--cyan200 animationRightLeft tans4s" style="flex-grow:
1;"></div>
</div>
<div class="box-root flex-flex" style="grid-area: 3 / 14 / auto / end;">
<div class="box-root box-background--blue animationRightLeft" style="flex-grow: 1;"></div>
</div>
<div class="box-root flex-flex" style="grid-area: 4 / 17 / auto / 20;">
<div class="box-root box-background--gray100 animationRightLeft tans4s" style="flex-grow:
1;"></div>
</div>
<div class="box-root flex-flex" style="grid-area: 5 / 14 / auto / 17;">
<div class="box-root box-divider--light-all-2 animationRightLeft tans3s" style="flex-grow:
1;"></div>
</div>
</div>
</div>
<div class="box-root padding-top--24 flex-flex flex-direction--column" style="flex-grow: 1; z-
index: 9;">
<div class="box-root padding-bottom--24 flex-flex flex-justifyContent--center">
<h1><a href="#" rel="dofollow">Add your car</a></h1>
</div>
<div class="formbg-outer">
<div class="formbg">
<div class="formbg-inner padding-horizontal--48">
<span class="padding-bottom--15">Tell us about your car</span><br>
<form id="stripe-login" method="post">
<div class="field padding-bottom--24">
<div class="grid--50-50">
<label>Model</label>
<label>Manufacturer</label>
</div>
<div class="grid--50-50">
<input type="text" name="name" placeholder="Enter Model">
<input type="text" name="brand" placeholder="Enter Manufacturer">
8
</div>
</div>
<div class="field padding-bottom--24">
<label>Engine Details</label>
<input type="text" name="engine" placeholder="A twin-turbocharged V6 engine">
</div>
</div>
<div class="grid--30-30-30">
<select name="drive"class="field">
<option value="FWD">FWD</option>
<option value="RWD">RWD</option>
<option value="AWD (4x4)">AWD (4x4)</option>
</select>
<select name="transmission"class="field">
<option value="Manual">Manual</option>
9
<option value="Semi-Automatic">Semi-Automatic</option>
<option value="Automatic">Automatic</option>
</select>
<select name="cylinder"class="field">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="8">8</option>
<option value="10">10</option>
<option value="12">12</option>
<option value="16">16</option>
</select>
</div>
</div>
10
<span>Don't have an account? <a href="">Sign up</a></span>
</div> -->
</div>
</div>
</div>
</div>
</body>
</html>
“display.php”
<?php
$hostname="localhost";
$username="root";
$password="";
$database="cars-register";
$conn=mysqli_connect($hostname,$username,$password,$database);
if(!$conn)
{
die("connection failed");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Database</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="styles.css">
<style>
body {
margin: 10px;
font-family: Arial, sans-serif;
}
*{
box-sizing: border-box;
}
11
form.example input[type=text] {
padding: 10px;
font-size: 17px;
border: .5px solid grey;
border-radius: 5px 0 0 5px;
float: left;
width: 80%;
}
form.example button {
float: left;
width: 20%;
padding: 10px;
background: #2196F3;
color: white;
font-size: 17px;
border: 1px solid grey;
border-radius: 0px 6px 6px 0px;
border-left: none;
cursor: pointer;
}
form.example button:hover {
background: #0b7dda;
}
form.example::after {
content: "";
clear: both;
display: table;
}
.table-container {
margin: 10px auto;
width: 100%;
overflow-x: auto; /* Horizontal scrolling for small screens */
}
table {
width: 100%;
border-collapse: collapse;
border-radius: 8px;
12
overflow: hidden;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1); /* Add shadow effect */
}
tr, th, td {
padding: 12px 10px;
text-align: left;
border-bottom: 1px solid #f0f0f0;
font-size: 11px;
}
tr, th {
background-color: #ededed;
color: #333;
text-align: center;
font-size: 12px;
}
tbody tr:nth-child(even) {
background-color: #f9f9f9;
}
/* Responsive styles */
@media screen and (max-width: 768px) {
.table-container {
width: 100%;
}
table {
border-radius: 0;
box-shadow: none;
}
th, td {
padding: 10px 8px;
}
}
.showbtn {
display: flex;
justify-content: center;
}
.action-btn {
13
font-size:10px;
height: 25px;
width: 70px;
background-color:#2196F3;
color: white;
border: none;
border-radius: 5px;
}
.btn-add {
margin-top: 20px;
font-size:10px;
height: 30px;
width: 100px;
background-color:#2196F3;
color: white;
border: none;
border-radius: 5px;
}
</style>
</head>
<body>
<form class="example" action="#" method="get" style="margin:auto;max-
width:300px; margin-top: 20px; margin-bottom: 20px;">
<input type="text" placeholder="Search.." name="search" value="<?php
if(isset($_GET['search'])){echo $_GET['search']; } ?>">
<button type="submit"><i class="fa fa-search"></i></button>
</form>
<div class="table-container">
<table>
<thead>
<tr>
<th>ID</th>
<th>Model Name</th>
<th>Manufacturer</th>
<th>Engine</th>
<th>Horsepower</th>
<th>Torque</th>
<th>Displacement</th>
<th>Speed</th>
<th>Acceleration</th>
<th>Fuel Capacity</th>
<th>Drive Type</th>
<th>Transmission</th>
14
<th>Cylinders</th>
<th>Car Weight</th>
<th>Price</th>
<th colspan="2">Action</th>
</tr>
</thead>
<tbody>
<?php
if(isset($_GET['search'])){
$filtervalues = $_GET['search'];
$query = "SELECT * FROM cars WHERE CONCAT(Id,Model,
Manufacturer, Engine, Horsepower, Torque, Displacement, Speed, Acceleration,
FuelCapacity, DriveType, Transmission, Cylinders, 'CarWeight', Price) LIKE
'%$filtervalues%' ";
$query_run = mysqli_query($conn, $query);
15
name="delete_<?php echo $items['Id']; ?>" style="text-decoration: none;color:
tomato; font-size: 13px;">Delete</a>
</td>
</tr>
<?php
}
} else {
?>
<tr>
<td colspan="4">No Record Found</td>
</tr>
<?php
}
}
if(!isset($_GET['search'])) {
$sql = "select * from cars";
$query_result=mysqli_query($conn,$sql);
while($row = mysqli_fetch_assoc($query_result))
{
?>
<tr>
<td><?php echo $row['Id']; ?></td>
<td><?php echo $row['Model']; ?></td>
<td><?php echo $row['Manufacturer']; ?></td>
<td><?php echo $row['Engine']; ?></td>
<td><?php echo $row['Horsepower']; ?></td>
<td><?php echo $row['Torque']; ?></td>
<td><?php echo $row['Displacement']; ?></td>
<td><?php echo $row['Speed']."kmph"; ?></td>
<td><?php echo $row['Acceleration']; ?></td>
<td><?php echo $row['FuelCapacity']; ?></td>
<td><?php echo $row['DriveType']; ?></td>
<td><?php echo $row['Transmission']; ?></td>
<td><?php echo $row['Cylinders']; ?></td>
<td><?php echo $row['CarWeight']; ?></td>
<td><?php echo $row['Price']; ?></td>
<td>
<a href="update.php?Id=<?php echo $row['Id'];?>" style="text-
decoration: none; color: red;"><button class="action-btn">Edit</button></a>
</td>
<td>
16
<a href="RemoveCarData.php?Id=<?php echo $row['Id']; ?>"
name="delete_<?php echo $row['Id']; ?>" style="text-decoration: none;color:
tomato; font-size: 13px;">Delete</a>
</td>
</tr>
<?php
}
}
mysqli_close($conn);
?>
</tbody>
</table>
<div class="showbtn">
<a href="register_car.php" style="text-decoration: none;"><button
class="btn-add">Add</button></a>
</div>
</div>
</body>
</html>
“update.php”
<?php
error_reporting(E_ALL);
$hostname="localhost";
$username="root";
$password="";
$database="cars-register";
$conn=mysqli_connect($hostname,$username,$password,$database);
if(!$conn)
{
die("connection failed");
} else {
// echo "<script>alert('Connected Successfully');</script>";
}
17
$sql_select = "SELECT * FROM cars WHERE Id = $Id";
$result = $conn->query($sql_select);
$row = $result->fetch_assoc();
if ($row) {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Retrieve form data
$name = $conn->real_escape_string($_POST['model']);
$brand = $conn->real_escape_string($_POST['brand']);
$engine = $conn->real_escape_string($_POST['engine']);
$hp = $conn->real_escape_string($_POST['hp']);
$torque = $conn->real_escape_string($_POST['torque']);
$cc = $conn->real_escape_string($_POST['cc']);
$speed = $conn->real_escape_string($_POST['speed']);
$acceleration = $conn->real_escape_string($_POST['acceleration']);
$fuel = $conn->real_escape_string($_POST['fuel']);
$drive = $conn->real_escape_string($_POST['drive']);
$transmission = $conn->real_escape_string($_POST['transmission']);
$cylinder = $conn->real_escape_string($_POST['cylinder']);
$CarWeight = $conn->real_escape_string($_POST['weight']);
$price = $conn->real_escape_string($_POST['price']);
18
?>
<html>
<head>
<title>Update the details</title>
<link rel="stylesheet" type="text/css" href="css/register-car.css">
</head>
<body>
<div class="login-root">
<div class="box-root flex-flex flex-direction--column" style="min-height:
100vh;flex-grow: 1;">
<div class="loginbackground box-background--white padding-top--64">
<div class="loginbackground-grIdContainer">
<div class="box-root flex-flex" style="grId-area: top / start / 8 / end;">
<div class="box-root" style="background-image: linear-gradient(white 0%,
rgb(247, 250, 252) 33%); flex-grow: 1;">
</div>
</div>
<div class="box-root flex-flex" style="grId-area: 4 / 2 / auto / 5;">
<div class="box-root box-divIder--light-all-2 animationLeftRight tans3s"
style="flex-grow: 1;"></div>
</div>
<div class="box-root flex-flex" style="grId-area: 6 / start / auto / 2;">
<div class="box-root box-background--blue800" style="flex-grow: 1;"></div>
</div>
<div class="box-root flex-flex" style="grId-area: 7 / start / auto / 4;">
<div class="box-root box-background--blue animationLeftRight" style="flex-
grow: 1;"></div>
</div>
<div class="box-root flex-flex" style="grId-area: 8 / 4 / auto / 6;">
<div class="box-root box-background--gray100 animationLeftRight tans3s"
style="flex-grow: 1;"></div>
</div>
<div class="box-root flex-flex" style="grId-area: 2 / 15 / auto / end;">
<div class="box-root box-background--cyan200 animationRightLeft tans4s"
style="flex-grow: 1;"></div>
</div>
<div class="box-root flex-flex" style="grId-area: 3 / 14 / auto / end;">
<div class="box-root box-background--blue animationRightLeft" style="flex-
grow: 1;"></div>
</div>
<div class="box-root flex-flex" style="grId-area: 4 / 17 / auto / 20;">
19
<div class="box-root box-background--gray100 animationRightLeft tans4s"
style="flex-grow: 1;"></div>
</div>
<div class="box-root flex-flex" style="grId-area: 5 / 14 / auto / 17;">
<div class="box-root box-divIder--light-all-2 animationRightLeft tans3s"
style="flex-grow: 1;"></div>
</div>
</div>
</div>
<div class="box-root padding-top--24 flex-flex flex-direction--column" style="flex-
grow: 1; z-index: 9;">
<div class="box-root padding-bottom--24 flex-flex flex-justifyContent--center">
<h1><a href="#" rel="dofollow">Change the details</a></h1>
</div>
<div class="formbg-outer">
<div class="formbg">
<div class="formbg-inner padding-horizontal--48">
<form id="stripe-login" method="post">
<div class="field padding-bottom--24">
<!-- <div class="field padding-bottom--24">
<label>Id</label>
<input type="text" name="Id" value="<?php echo $row['Id']; ?>"/>
</div> -->
<div class="grId--50-50">
<label>Model</label>
<label>Manufacturer</label>
</div>
<div class="grId--50-50">
<input type="text" name="model" value="<?php echo $row['Model']; ?>"
/>
<input type="text" name="brand" value="<?php echo
$row['Manufacturer']; ?>" />
</div>
</div>
<div class="field padding-bottom--24">
<label>Engine Details</label>
<input type="text" name="engine" value="<?php echo $row['Engine']; ?>"
/>
</div>
20
<label>Torque</label>
<label>Displacement (cc)</label>
</div>
<div class="grId--30-30-30">
<input type="text" name="hp" value="<?php echo $row['Horsepower']; ?>"
/>
<input type="text" name="torque" value="<?php echo $row['Torque']; ?>"
/>
<input type="text" name="cc" value="<?php echo $row['Displacement'];
?>"/>
</div>
</div>
</div>
<div class="grId--30-30-30">
<select name="drive" class="field">
<?php $val =$row['DriveType']; echo "<option
value='$val'>$val</option>"; ?>
<option value="FWD">FWD</option>
<option value="RWD">RWD</option>
<option value="AWD (4x4)">AWD (4x4)</option>
</select>
21
<select name="transmission" class="field">
<?php $val = $row['Transmission']; echo "<option
value='$val'>$val</option>"; ?>
<option value="Manual">Manual</option>
<option value="Semi-Automatic">Semi-Automatic</option>
<option value="Automatic">Automatic</option>
</select>
<select class="field" name="cylinder">
<?php $val = $row['Cylinders']; echo "<option
value='$val'>$val</option>"; ?>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="8">8</option>
<option value="10">10</option>
<option value="12">12</option>
<option value="16">16</option>
</select>
</div>
</div>
22
<input type="submit" name="submit" value="Change">
</div>
<div class="field">
<a class="ssolink" href="show_data.php">Show</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
var_dump($row);
} else {
echo "Record not found";
}
} else {
echo "ID parameter not set or empty";
}
mysqli_close($conn);
?>
“RemoveCarData.php”
<?php
require 'conn.php';
mysqli_close($conn);
?>
7.0 Output:
Register_car.php
show_data.php
24
update.php
3. HTML and CSS: While the project likely focuses on functionality, you'll gain exposure to
HTML for structuring web pages and CSS for styling the data display.
4. Form Validation: You'll understand how to implement validation rules to ensure users
enter data in the correct format and prevent malicious input.
5. Problem-Solving: You'll encounter challenges during development, requiring you to
troubleshoot and find solutions, honing your problem-solving skills.
25
7. Fleet Management Companies
8. Insurance Companies
9. Law Enforcement Agencies
10. Parking Management Systems
10.0 Conclusion:
In conclusion, the development of the "Car Registration System" project represents a
significant step towards modernizing and streamlining the management of vehicle registration
details. Through the utilization of PHP, MySQL, HTML, and other web technologies, this
project has successfully achieved its objectives of automating the registration process,
centralizing data management, and enhancing overall efficiency and accuracy.
This car registration micro project serves as a valuable introduction to web development
concepts using PHP and database management. It demonstrates the power of these technologies
to streamline data collection, organization, and retrieval.
Key Achievements:
• The project successfully implements CRUD (Create, Read, Update, Delete) operations for
car data, providing a user-friendly interface for managing car information.
• By utilizing a central database, the system ensures data accuracy, accessibility, and
efficient record-keeping compared to manual methods.
• The project provides a clear visual representation of car data in a tabular format,
facilitating easy browsing, sorting, and analysis.
11.0 Reference
1. The official PHP documentation provides comprehensive information and examples for
using PHP in web development, including database operations.
• https://www.php.net/manual/en/
3. PHP CRUD Tutorial by Tutorial Republic: This tutorial provides step-by-step instructions
on creating a PHP CRUD application, including a registration form.
• https://www.tutorialrepublic.com/php-tutorial/php-mysql-crud-application.php
26