-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup.php
More file actions
36 lines (31 loc) · 902 Bytes
/
signup.php
File metadata and controls
36 lines (31 loc) · 902 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
32
33
34
35
36
<?php
include_once('Dao.php');
function clog( $data ){
echo '<script>';
echo 'console.log("'. $data .'")';
echo '</script>';
}
if($_SERVER['REQUEST_METHOD'] == "POST") {
clog("signup POST1");
if(validPassword($_POST['password1'], $_POST['password2'])
&& validUser($_POST['user'])) {
clog("signup POST2");
$pass_hash = password_hash($_POST['password1'], PASSWORD_BCRYPT);
Dao::insertUser($_POST['user'], $pass_hash);
clog("signup POST3");
header('Location: login.php');
}
}
include("signup.html");
function validUser($user) {
if(Dao::userExists($user) || $user == '')
return false;
return true;
}
function validPassword($pass1, $pass2) {
return (($pass1 == $pass2) && strong($pass1));
}
function strong($pass) {
return true;
}
?>