-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsell1.php
39 lines (28 loc) · 1.1 KB
/
sell1.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
<?php
session_start();
$db = mysqli_connect("localhost", "root", "", "users");
$itemname=mysqli_real_escape_string($db,$_POST['itemname']);
$MobileNo=mysqli_real_escape_string($db,$_POST['MobileNo']);
$price=mysqli_real_escape_string($db,$_POST['price']);
$comment=mysqli_real_escape_string($db,$_POST['comment']);
$image =mysqli_real_escape_string($db, $_FILES['image']['name']);
if(isset($_POST['submit']))
{
$target_dir = "images/";
$target_file = $target_dir . basename($_FILES['image']['tmp_name']);
echo "Sorry, file already exists.";
if (move_uploaded_file($_FILES['image']['tmp_name'], $target_file))
{
echo "The file ". basename( $_FILES['image']['tmp_name']). " has been uploaded.";
$sql = "INSERT INTO selldb (itemname , MobileNo , price , comment , image)
VALUES ('$itemname','$MobileNo','$price', '$comment','$image' )";
mysqli_query($db, $sql);
header("location:page3.html");
}
else
{
echo "Sorry, there was an error uploading your file.";
}
}
mysqli_close($db);
?>