-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassign1.php
42 lines (31 loc) · 974 Bytes
/
assign1.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
<?php
//Start the session to see if the user is authenticated user.
$type = $_POST['type'];
$id = $_POST['id'];
$date = $_POST['date'];
//If all valtypeations 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 assign VALUES ('$type','$id','$date')";
//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="assign.html"';
echo '</script>';
}
?>