-
Notifications
You must be signed in to change notification settings - Fork 0
/
gone.php
47 lines (30 loc) · 1.03 KB
/
gone.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$userN = htmlspecialchars(trim($_POST["userN"]));
$pwd = trim($_POST["pwd"]);
$email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);
if (empty($userN) || empty($pwd)) {
header("Location: ../test.php");
exit();
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
header("Location: ../test.php?error=invalidemail");
exit();
}
try {
$hashed_pwd = password_hash($pwd, PASSWORD_DEFAULT);
require_once "handle.php";
$query = "INSERT INTO userdb (userName, pwd, email) VALUES (?, ?, ?);";
$stmt = $pdo->prepare($query);
$stmt->execute([$userN, $hashed_pwd, $email]);
$pdo = null;
$stmt = null;
header("Location: ../test.php?success=true");
exit();
} catch (PDOException $e) {
die("Query failed: " . $e->getMessage());
}
} else {
header("Location: ../test.php");
exit();
}