-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.php
36 lines (29 loc) · 915 Bytes
/
auth.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
<?php
session_start();
#db connnection
mysql_connect('localhost','root','');
mysql_select_db('multido') or die(mysql_error());
if($_POST){
foreach ($_POST as $key => $value) {
$$key = $value;
}
$query = "select * from members where uname = '".$username."' ";
$query .= "and password = '".$password."' OR email = '".$username."' and password = '".$password."';";
$result = mysql_query($query);
$thequery_rst = @mysql_result($result,0);
$grant_access = ($thequery_rst == true ? true : false);
$php_array_result = array($username,$password,$grant_access,$thequery_rst[0]);
if($grant_access==true){
$_SESSION['logon']=true;
}else{
$_SESSION['logon']=false;
}
$_SESSION['uid']=$thequery_rst[0];
// Send the correct MIME header and echo out the JSON string
header("Content-type: application/json");
echo json_encode($php_array_result);
}else{
session_destroy();
header("Location: logon.php"); }
exit();
?>