-
Notifications
You must be signed in to change notification settings - Fork 0
/
2wheeler.php
83 lines (61 loc) · 2.46 KB
/
2wheeler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
require_once ('connection.php');
if(isset($_POST['Submit1']))
{
$Vehicleid = (int)$_POST['V-id'];
$Cost = (int)$_POST['cost'];
$Type = mysqli_real_escape_string($con,$_POST['V-type']);
$Vehiclename = mysqli_real_escape_string($con,$_POST['V-name']);
$Manufacturedate= $_POST['manufacture-date'];
$Manufacturedate = date("Y/m/d", strtotime($Manufacturedate));
$Model = (int)$_POST['model'];
// to add image to database
$filename = addslashes($_FILES['file']['name']);
$tmpname = addslashes(file_get_contents($_FILES['file']['tmp_name']));
$filetype = addslashes($_FILES['file']['type']);
$filesize = addslashes($_FILES['file']['size']);
$array = array('jpg','jpeg');
$ext = pathinfo($filename, PATHINFO_EXTENSION);
//display
$res = mysqli_query($con,"select * from twowheeler");
//check for all the fields to be filled
if(empty($Vehicleid) || empty($Cost) || empty($Type) || empty($Vehiclename) || empty($Model))
{
echo 'Please fill all the fields';
}
else
{
$sql = "insert into twowheeler values ('$Vehicleid','$Vehiclename','$Cost','$Type','$Model','$Manufacturedate','$filename')";
$result = mysqli_query($con,$sql);
if ($result)
{
echo 'Record is saved in database';
}
else
{
echo 'Check your query';
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>PHP File Upload example</title>
<link rel="stylesheet" href="style6.css">
</head>
<body>
<form action="#" enctype="multipart/form-data" method="post">
<h1>Vehicle Details</h1>
<input type="number" name="V-id" placeholder="Vehicle-Id" class="details" required>
<input type="text" name="V-name" placeholder="Vehicle name" class="details" required>
<input type="text" name="V-type" placeholder="Vehicle type" class="details" required>
<input type="number" name="cost" placeholder="Cost" class="details" required>
<input type="date" name="manufacture-date" placeholder="Manufacture-date" class="details" required>
<input type="number" name="model" placeholder="Model" class="details" required>
Select Image:
<input type="file" name="file" class="image"><br/>
<input type="submit" value="Upload" name="Submit1" class="upload" > <br/>
</form>
</body>
</html>