-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert.php
More file actions
37 lines (33 loc) · 1.01 KB
/
insert.php
File metadata and controls
37 lines (33 loc) · 1.01 KB
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
<?php
$conn = mysqli_connect("localhost","admin","123456","sprinkles");
if (mysqli_connect_error())
{
echo "Can't connect to database" ;
die();
}
else {
if (isset($_POST["insertdata"])) {
$name = $_POST["product"];
$price = $_POST["price"];
$category = $_POST['gridRadios'];
$des = $_POST['description'];
$qty = $_POST['Quantity'];
$img=$_POST['image'];
$qry = "INSERT INTO product (`name`, price,description,category,quantity,img) VALUES ('$name','$price','$des','$category' ,'$qty','$img')";
$res= $conn->query($qry);
if ($res) {
echo '<script> alert("Data saved");</script>';
header('location:admin0.php');
} else
echo '<script> alert("Data not saved");</script>';
}
}
?>
/*if($_POST["operation"] == "Add")
{
$statement = $connection->prepare(");
}
if($_POST["operation"] == "Edit")
{
$statement = $connection->prepare("UPDATE product SET name = :course, price = :students WHERE id = :id");
}*/