-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.php
31 lines (26 loc) · 838 Bytes
/
check.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
<?php
$emailArray = array();
$data = array( "email" => "", "password" => "" );
//$usernames = array( "martynj", "admin", "bob", "dave", "fred" );
$emails = $conn->query( "SELECT email from customers" );
$emails->execute();
foreach ( $emails as $email ){
$emailArray .= $email;
}
if( isset($_POST["email"]) ) {
if( in_array( $_POST["email"], $emailArray ) ) {
$data["email"] = "inuse";
}
}
if( isset( $_POST["email"] ) ) {
if( $_POST["email"] != "" && !preg_match( "/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $_POST["email"] ) ) {
$data["email"] = "notvalid";
}
}
if( isset($_POST["password"]) && isset($_POST["password_again"]) ) {
if( $_POST["password_again"] != "" && $_POST["password"] != $_POST["password_again"] ) {
$data["password"] = "missmatch";
}
}
echo json_encode( $data );
?>