forked from yashasvi211/shopcity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
register.php
30 lines (25 loc) · 866 Bytes
/
register.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
<?php
// Database connection parameters
$conn = mysqli_connect('localhost', 'root', '', 'shopcity');
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Process registration form
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST["name"];
$address = $_POST["address"];
$phone = $_POST["phone"];
$email = $_POST["email"]; //this done by ashu
$password = password_hash($_POST["password"], PASSWORD_DEFAULT);
// Insert user data into the database
$sql = "INSERT INTO users (name, address, phone, email, password) VALUES ('$name', '$address', '$phone', '$email', '$password')";
if ($conn->query($sql) === TRUE) {
echo "Registration successful!";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
// Close connection
$conn->close();
?>