-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddData.php
More file actions
23 lines (17 loc) · 715 Bytes
/
addData.php
File metadata and controls
23 lines (17 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
$dbconnect = mysqli_connect('localhost', 'siteAdmin','admin');
if($dbconnect->connect_error)
die("Could not connect at the database");
mysqli_select_db($dbconnect, 'site');
$name = $_POST['name'];
$price = $_POST['price'];
$status = $_POST['status'];
$username = $_SESSION['username'];
if($status == "Want")
$query = "INSERT INTO $username (name, price, status) VALUES ('$name', '$price', 'Want')";
else
$query = "INSERT INTO $username (name, price, status) VALUES ('$name', '$price', 'Own')";
$add = mysqli_query($dbconnect, $query)
or die("Error: Could not add game to the database.");
header("Location: profile.php");
?>