-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.php
executable file
·38 lines (30 loc) · 899 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
32
33
34
35
36
37
<?php
session_start();
if($_SERVER['REQUEST_METHOD']=="POST"){
mysql_connect('localhost',"root","iiit123");
mysql_select_db("postnoon") or die("Unable to connect to Database");
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$result = mysql_query("SELECT * FROM users where username = '$username' AND password = '$password'");
$num = mysql_num_rows($result);
while($num--)
{
$row= mysql_fetch_array($result);
$_SESSION['isadmin']=$row[isadmin];
$_SESSION['username']=$row[username];
if($row[isadmin]==1)
break;
}
if(mysql_num_rows($result) > 0){
$_SESSION['is_logged_in'] = 1;
$_SESSION['failed'] = 0;
header('location:index.php');
}
else
{
$_SESSION['is_logged_in'] = 0;
$_SESSION['failed'] = 1;
header('location:login.php');
}
}
?>