-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert.php
52 lines (41 loc) · 1.32 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
<!DOCTYPE html>
<html>
<head>
<title>Insert Page page</title>
</head>
<body>
<center>
<?php
// servername => localhost
// username => root
// password => empty
// database name => staff
$conn = mysqli_connect("localhost:8080", "root", "", "stem website");
// Check connection
if($conn === false){
die("ERROR: Could not connect. "
. mysqli_connect_error());
}
// Taking values from the form data(input)
$user_name = $_REQUEST['user_name'];
$user_pass = $_REQUEST['user_pass'];
// Performing insert query execution
if ($_POST["user_pass"] === $_POST["pass_confirm"]) {
$sql = "INSERT INTO login_data VALUES ('$user_name',
'$user_pass')";
if(mysqli_query($conn, $sql)){
header('Location: index.html');
} else{
echo "ERROR: Hush! Sorry $sql. "
. mysqli_error($conn);
}
}
else {
header('Location: ' . $_SERVER['HTTP_REFERER']);
}
// Close connection
mysqli_close($conn);
?>
</center>
</body>
</html>