-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
134 lines (130 loc) · 5.58 KB
/
signup.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
require_once('common.php');
if(isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === 1)
{
header("Location: /");
exit;
}
if(isset($_POST['submit']))
{
if(isset($_POST['hiddenval']) && $_POST['hiddenval'] === '1')
{
$email = empty(trim($_POST['email'])) ? NULL : mysqli_real_escape_string($link, trim($_POST['email']));
$password = empty(trim($_POST['password'])) ? NULL : mysqli_real_escape_string($link, trim($_POST['password']));
$cpassword = empty(trim($_POST['cpassword'])) ? NULL : mysqli_real_escape_string($link, trim($_POST['cpassword']));
$phoneNo = empty(trim($_POST['number'])) ? NULL : mysqli_real_escape_string($link, trim($_POST['number']));
$name = empty(trim($_POST['name'])) ? NULL : mysqli_real_escape_string($link, trim($_POST['name']));
if($email == NULL || $password == NULL || $name == NULL || !filter_var($email,FILTER_VALIDATE_EMAIL))
{
$msg = _("An error ocurred.");
}
else if(isEmailInDB($email))
{
$msg = _("This email is already present in our database!");
}
else if($password === $cpassword && !isEmailInDB($email)) //SECOND CONDITION NOT NECESSARY (?)
{
if(!is_null($phoneNo) && isNumberInDB($phoneNo))
{
$msg = _("Phone number already exists in our database");
}
else
{
$password = getPasswordHash($cpassword);
registerUser($email, $password, $phoneNo, $name);
header("Location: signedup.html");
exit;
}
}
else
{
$msg = _("The passwords you entered didn't match");
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Report problems in your area so they can be fixed." />
<title>FixMyStreet.net</title>
<link rel="stylesheet" href="css/pure/pure-min.css" />
<link rel="stylesheet" href="css/pure/grids-responsive-min.css" />
<script defer src="fontawesome-free-5.15.2-web/js/all.min.js"></script>
<link rel="stylesheet" href="fontawesome-free-5.15.2-web/css/all.min.css" />
<link rel="shortcut icon" href="favicon.svg" type="image/x-icon">
<link rel="stylesheet" href="css/styles.css" />
</head>
<body>
<?=$header?>
<div class="dash-header signup">
<div class="splash">
<h1 id="sign-up">Sign Up</h1>
<div id="" class="">
<div id="signup-form">
<form action="<?= $_SERVER['PHP_SELF'] ?>" method="post" class="pure-form pure-form-stacked">
<fieldset>
<?php
if(isset($msg) && $msg != '')
{
?><div style='text-align:center; color:black'><?= $msg ?></div>
<?php } ?>
<input type="hidden" value="1" name="hiddenval">
<div class="pure-control-group">
<label for="aligned-number">Phone number</label>
<input type="tel" name="number" id="aligned-number" placeholder="Phone number" />
<span class="pure-form-message-inline">This is an optional field.</span>
</div>
<div class="pure-control-group">
<label for="aligned-name">Name</label>
<input type="text" name="name" id="aligned-name" placeholder="Your name" />
</div>
<div class="pure-control-group">
<label for="aligned-email">Email Address</label>
<input type="email" name="email" id="aligned-email" placeholder="Email Address" />
</div>
<div class="pure-control-group">
<label for="aligned-password">Password</label>
<input type="password" name="password" id="aligned-password" placeholder="Password" />
</div>
<div class="pure-control-group">
<label for="aligned-password">Confirm Password</label>
<input type="password" name="cpassword" id="aligned-cpassword" onkeyup="validate()" placeholder="Confirm password" />
</div>
<div class="pure-controls">
<!-- <label for="aligned-cb" class="pure-checkbox">
<input type="checkbox" id="aligned-cb" /> I've read
the terms and conditions</label
> -->
<button name="submit" type="submit" id="btn-submit" class="pure-button pure-button-primary">
Submit
</button>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
<!-- <div class="dash-content-wrapper"> -->
<!-- <div id="signup-content" class="content"> -->
<!-- </div> -->
</div>
<?=$footer?>
</body>
<script>
function validate() {
const pass = document.getElementById("aligned-password");
const cpass = document.getElementById("aligned-cpassword");
if(cpass.value !== pass.value) {
cpass.style.borderColor = "red";
document.getElementById("btn-submit").setAttribute("disabled", "");
} else {
cpass.style.borderColor = "#66ff00";
document.getElementById("btn-submit").removeAttribute("disabled");
}
}
</script>
</html>