-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsignupConfirmation.php
54 lines (49 loc) · 1.53 KB
/
signupConfirmation.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
48
49
50
51
52
53
54
<?php
include_once("config.php");
// Open database connection
$conn = mysqli_connect(DB_HOST_NAME, DB_USER, DB_PASS, DB_NAME);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$email = trim($_POST['eMail']);
$firstName = trim($_POST['fName']);
$lastName = trim($_POST['lName']);
$dateOfBirth = $_POST['bDay'] . "00:00:00";
$password = trim($_POST['pWord1']);
// server side input validations
if(!isset($email) || !isset($firstName) || !isset($lastName) || !isset($dateOfBirth) || !isset($password)){
header('Location: signup.php');
}
$sql = "INSERT INTO Users (email, firstName, lastName, dateOfBirth, password)
VALUES ('$email','$firstName','$lastName','$dateOfBirth','$password');";
$success = false;
$redirect = 'signup.php';
//attempt to create new record
if (mysqli_query($conn, $sql)) {
$redirect = 'login.php';
$success = true;
}
mysqli_close($conn);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<META HTTP-EQUIV="Refresh" Content="3; URL=<?php echo $redirect; ?>">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css"></link>
<title>Sign Up</title>
</head>
<body class="infoPage">
<?php
if ($success) {
echo "Sign-up successful. Welcome to URspace!";
echo "<br/>";
echo "Redirecting...";
} else {
echo "User email already exists.";
echo "<br/>";
echo "Redirecting...";
}
?>
</body>
</html>