forked from chriszhou1992/ABCD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate.php
65 lines (58 loc) · 1.33 KB
/
validate.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
<?php
$name = $_POST["name"];
$email = $_POST["email"];
$password = $_POST["password"];
$confirm = $_POST["confirm"];
if($name !== "no"):
if(filter_var($name, FILTER_VALIDATE_EMAIL)) {
echo "invalid";
return;
}
$count = 0;
for($i=0; $i<strlen($name); $i++):
$curC = substr($name, $i, 1);
if(ctype_alpha($curC)):
$count += 1;
endif;
if($count >= 6):
require_once 'classes/Accounts.php';
new Accounts();
if(Accounts::nameExists($name)) {
echo "exists";
return;
}
echo "true";
break;
endif;
endfor;
if($count < 6):
echo "false";
endif;
endif;
if($email !== "no"):
if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
require_once 'classes/Accounts.php';
new Accounts();
if(Accounts::emailExists($email)) {
echo "exists";
return;
}
echo "true";
} else {
echo "false";
}
endif;
if($password !== "no" && $confirm == "no"):
if(strlen($password) >= 6) {
echo "true";
} else {
echo "false";
}
endif;
if($password !== "no" && $confirm !== "no"):
if($password === $confirm) {
echo "true";
} else {
echo "false";
}
endif;