This repository has been archived by the owner on Apr 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
check.php
37 lines (37 loc) · 1.7 KB
/
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
32
33
34
35
36
37
<?php
require_once('config.php');
if(isset($_POST["user"]))
{
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')
die();
$username = strtolower(trim($_POST["user"]));
$username = filter_var($username, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW|FILTER_FLAG_STRIP_HIGH);
$username = htmlspecialchars($username, ENT_QUOTES);
$params = array($username);
$opts = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$sql = "SELECT Name FROM Account WHERE Name= ?";
$results = sqlsrv_query($mssql, $sql, $params, $opts);
$username_exist = sqlsrv_num_rows($results);
if($username_exist == 1)
die('<span style="color:#F44336;"><i class="fa fa-ban" aria-hidden="true"></i> Username not available! Try again.</span>');
else
die('<span style="color:#8BC34A;"><i class="fa fa-check" aria-hidden="true"></i> Available</span>');
}
if(isset($_POST["mail"]))
{
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')
die();
$Email = strtolower(trim($_POST["mail"]));
$Email = filter_var($Email, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW|FILTER_FLAG_STRIP_HIGH);
$Email = htmlspecialchars($Email, ENT_QUOTES);
$params = array($Email);
$opts = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$sql = "SELECT Name FROM Account WHERE Email= ?";
$results = sqlsrv_query($mssql, $sql, $params, $opts);
$Email_exist = sqlsrv_num_rows($results);
if($Email_exist == 1)
die('<span style="color:#F44336;"><i class="fa fa-ban" aria-hidden="true"></i> Email not available! Try again.</span>');
else
die('<span style="color:#8BC34A;"><i class="fa fa-check" aria-hidden="true"></i> Available</span>');
}
?>