-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert.php
More file actions
29 lines (22 loc) · 910 Bytes
/
insert.php
File metadata and controls
29 lines (22 loc) · 910 Bytes
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
<?php
$conn = mysqli_connect("localhost", "root", "", "test1");
// Check connection
if($conn === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Escape user inputs for security
$uname = mysqli_real_escape_string($conn, $_POST['uname']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$pswd = mysqli_real_escape_string($conn, $_POST['pswd']);
$pswd2 = mysqli_real_escape_string($conn, $_POST['pswd2']);
// attempt insert query execution
$sql = "INSERT INTO signup (username, email, pass,cpass) VALUES ('$uname', '$email', '$pswd','$pswd2')";
if(mysqli_query($conn, $sql)){
echo "Records added successfully.";
header('Location: firstpage.html');
} else{
echo "ERROR: Could not able to execute. " ;
}
// close connection
mysqli_close($conn);
?>