Changes in html and Login/Register php
This commit is contained in:
15
register.php
15
register.php
@@ -11,14 +11,21 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// Hash the password
|
||||
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
|
||||
|
||||
// Insert user into the database
|
||||
$query = "INSERT INTO users (username, email, password) VALUES ('$username', '$email', '$hashed_password')";
|
||||
$result = mysqli_query($mysqli, $query);
|
||||
// Prepare and execute the SQL query using prepared statements
|
||||
$query = "INSERT INTO users (username, email, password) VALUES (?, ?, ?)";
|
||||
$stmt = $mysqli->prepare($query);
|
||||
$stmt->bind_param("sss", $username, $email, $hashed_password);
|
||||
|
||||
// Execute the statement
|
||||
$result = $stmt->execute();
|
||||
|
||||
if ($result) {
|
||||
echo "Registration successful. <a href='login.html'>Login here</a>.";
|
||||
} else {
|
||||
echo "Error: " . mysqli_error($mysqli);
|
||||
echo "Error: " . $mysqli->error;
|
||||
}
|
||||
|
||||
// Close the statement
|
||||
$stmt->close();
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user