-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup.php
More file actions
31 lines (27 loc) · 985 Bytes
/
Copy pathsignup.php
File metadata and controls
31 lines (27 loc) · 985 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
31
<?php
require 'config.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
$email = $_POST['email'];
$password = password_hash($_POST['password'], PASSWORD_BCRYPT);
// Check if email already exists
$sql = "SELECT * FROM Utilisateurs WHERE email = ?";
$stmt = $connection ->prepare($sql);
$stmt->bind_param("s", $email);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
header("Location: seconnect.php?error=email_exists");
} else {
// Insert new user
$sql = "INSERT INTO Utilisateurs (nom_utilisateur, email, mot_de_passe) VALUES (?, ?, ?)";
$stmt = $connection ->prepare($sql);
$stmt->bind_param("sss", $name, $email, $password);
if ($stmt->execute()) {
header("Location: seconnect.php?success=account_created");
} else {
header("Location: seconnect.php?error=signup_failed");
}
}
}
?>