-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.php
49 lines (49 loc) · 1.43 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
session_start();
if(isset($_COOKIE['cookname'])){// && isset($_COOKIE['cookid'])){
$_SESSION['username'] = $_COOKIE['cookname'];
// $_SESSION['userid'] = $_COOKIE['cookid'];
}
if(isset($_SESSION['username'])){// && isset($_SESSION['userid'])){
//user logged in
}
else{
if(isset($_REQUEST['login'])){
if(isset($_REQUEST['username'])&&isset($_REQUEST['password'])){
if($_REQUEST['username']!=''&&$_REQUEST['password']!=''){
$userdetails=$db->getTableasArray("select user from user where name='".$db->__($_REQUEST['username'])."'");
if($userdetails){
if($userdetails[0]['password']==$_REQUEST['password']){
//sucessfull login set cookies and sessions
$_SESSION['username'] = $userdetails[0]['name'];
//$_SESSION['userid'] = $_COOKIE['cookid'];
if($_REQUEST['remember']=='yes'){
setcookie("cookname", $userdetails[0]['password'], time()+(3600*24*7));
}
}
else{
$_SESSION['err']="Incorrect password! Please check your password and re-enter";
header("Location: ?v=login");
exit;
}
}
else{
$_SESSION['err']="This username doesnot exist in our database! plz check and enter you login details again!";
header("Location: ?v=login");
exit;
}
}
else{
$_SESSION['err']="Username and password cannot be blank";
header("Location: ?v=login");
exit;
}
}
}
else{
//goto login form
header("Location: ?v=login");
exit;
}
}
?>