-
Notifications
You must be signed in to change notification settings - Fork 0
/
register_done.php
executable file
·59 lines (52 loc) · 1.34 KB
/
register_done.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
55
56
57
58
59
<?php
require_once "fbl_common.php";
$fields = ["email", "pw", "fname", "scr", "dob", "gender", "vis",
"stat", "loc"];
function validate_fields($fields) {
$missing = [];
foreach ($fields as $field) {
if (!isset($_POST[$field]) || $_POST[$field] == "") {
array_push($missing, $field);
}
}
return $missing;
}
$err = validate_fields($fields);
if ($err == []) {
db_connect($conn);
$creds = make_password($_POST["pw"]);
$salt = $creds[0];
$pw = $creds[1];
add_user($conn, $_POST["email"], $_POST["fname"], $_POST["scr"],
$_POST["dob"], $_POST["gender"], $_POST["vis"], $pw,
$salt, $_POST["stat"], $_POST["loc"]);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>FaceMagazine: Registering...</title>
</head>
<body>
<?php if ($err == []): ?>
<h1>Congratulations! </h1>
<p>You are now registered. Your details:</p>
<?php
foreach ($fields as $field) {
echo $field . "=" . $_POST[$field];
echo isset($_POST[$field]) ? "//set" : "//unset";
echo $_POST[$field] == "" ? "(blank)" : "(not blank)";
echo "<br/>";
}
?>
<p><a href="login.php">Return to login now</a></p>
<?php else: ?>
<p>Sorry, you didn't submit all the fields in your registration, or another
error occurred:</p><ul>
<?php
foreach ($err as $msg) {
echo "<li>" . $msg . "\n";
}
?></ul>
<?php endif ?>
</body>