-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInventory1.php
41 lines (30 loc) · 953 Bytes
/
Inventory1.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
<?php
//Start the session to see if the user is authenticated user.
$serial = $_POST['serial'];
$id = $_POST['id'];
//If all valserialations are correct, connect to MySQL and execute the query
//Connect to mysql server
$link = mysqli_connect('localhost', 'root', '');
//Check link to the mysql server
if(!$link){
die('Failed to connect to server: ' . mysqli_error());
}
//Select database
$db = mysqli_select_db($link,'armydb');
if(!$db){
die("Unable to select database");
}
//Create Insert query
$query = "INSERT INTO inventory VALUES ('$serial','$id')";
//Execute query
$results = mysqli_query($link,$query);
//Check if query executes successfully
if($results == FALSE)
{echo mysqli_error($link) ; }
else
{
echo '<script language="javascript">';
echo 'alert("Successfully Registered"); location.href="Inventory.php"';
echo '</script>';
}
?>