forked from cwerner6/databases-final-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert.php
executable file
·108 lines (86 loc) · 2.95 KB
/
insert.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html>
<head>
<title>Add New Record in MySQL Database</title>
</head>
<body>
<div style="height:900px; background-color: lightblue;" align="center">
<?php
require("tableshow.php");
require("dbconnect.php");
if(isset($_POST['add'])) {
if(! get_magic_quotes_gpc() ) {
$i_name = addslashes ($_POST['i_name']);
$i_dept = addslashes ($_POST['i_dept']);
} else {
$i_name = $_POST['i_name'];
$i_dept = $_POST['i_dept'];
}
$i_ID = $_POST['i_ID'];
$i_salary = $_POST['i_salary'];
echo " <br> Instructor table before insertion <br>";
show_instructor($conn);
$sql = "INSERT INTO instructor ".
"(ID,name, dept_name, salary) "."VALUES ".
"('$i_ID','$i_name','$i_dept', '$i_salary')";
//mysqli_select_db($conn,'university');
$retval = mysqli_query($conn, $sql);
if(! $retval ) {
die('Could not enter data: ' . mysqli_error($conn));
}
echo "Entered data successfully\n";
echo " <br> Instructor table after insertion <br>";
show_instructor($conn);
mysqli_close($conn);
}
else if(isset($_POST['show'])){
show_instructor($conn);
}
else {
?>
<br><br><br><br>
<p>Enter Instructor information for insertion <br> </p>
<form method = "post" action = "<?php $_PHP_SELF ?>">
<table width = "600" border = "0" cellspacing = "1" cellpadding = "2">
<tr>
<td width = "250">ID</td>
<td>
<input name = "i_ID" type = "text" id = "i_ID">
</td>
</tr>
<tr>
<td width = "250">Name</td>
<td>
<input name = "i_name" type = "text" id = "i_name">
</td>
</tr>
<tr>
<td width = "250">Department</td>
<td>
<input name = "i_dept" type = "text" id = "i_dept">
</td>
</tr>
<tr>
<td width = "250"> Salary</td>
<td> <input name="i_salary" type= "text" id = "i_salary"> </td>
</tr>
<tr>
<td width = "250"></td>
<td> </td>
</tr>
<tr>
<td width = "250"> </td>
<td>
<input name = "add" type = "submit" id = "add" value = "insert">
</td>
</tr>
</table>
<?php
}
?>
<hr width="50">
<a href="Frontpage.html" style="color:red;font-weight:bold;">Home</a>
<hr width="50">
</div>
</body>
</html>