-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconnect.php
More file actions
30 lines (27 loc) · 880 Bytes
/
connect.php
File metadata and controls
30 lines (27 loc) · 880 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
30
<?php
if (isset($_POST["fname"]) && isset($_POST["lname"]) && isset($_POST["username"]) && isset($_POST["password"])) {
$username= $_POST["username"];
$password= $_POST["password"];
$fname= $_POST["fname"];
$lname= $_POST["lname"];
// create connection
$conn = mysqli_connect("localhost", "root", "", "users");
// check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// register user
$sql = "INSERT INTO customers (fname, lname, username, password) VALUES ('$fname','$lname','$username', '$password')";
$results = mysqli_query($conn, $sql);
if ($results) {
echo "The user has been added.";
echo" Redirecting to the home page ...";
header("refresh:5;url=http://localhost/homepage.php");
} else {
echo mysqli_error($conn);
}
mysqli_close($conn); // close connection
} else {
echo "Form was not submitted.";
}
?>