-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconnect2.php
53 lines (40 loc) · 1.23 KB
/
connect2.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
<!DOCTYPE html>
<html>
<head>
<title>Insert employee data</title>
</head>
<body>
<center>
<?php
$servername = "localhost";
$username = "root";
$password = "Project7273@";
$db = "Library";
// get the post records
$empID = $_REQUEST['empID'];
$empFirst = $_REQUEST['empFirst'];
$empLast = $_REQUEST['empLast'];
// Create connection
$conn = new mysqli($servername, $username, $password, $db);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO Employee VALUES ('$empID',
'$empFirst','$empLast')";
if(mysqli_query($conn, $sql)){
echo "<h3>Data is stored in our database successfully."
. " Please browse your php my admin"
. " to view the updated data</h3>";
echo nl2br("\nEmployee ID:$empID\n First Name:$empFirst\n "
. "Last Name:$empLast");
} else{
echo "ERROR: Hush! Sorry $sql. "
. mysqli_error($conn);
}
// Close connection
mysqli_close($conn);
?>
</center>
</body>
</html>