-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.php
36 lines (31 loc) · 957 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();
// define variables and set to empty values
include("connection.php");
// $r=$conn->query("select * from admin");
// echo $r->num_rows;
$pass = $uname = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$uname = test_input($_POST["uname"]);
$pass = test_input($_POST["pass"]);
$sql="select * from admin where uname='".$uname."' AND pass='".$pass."'";
$r=$conn->query($sql);
echo $r->num_rows;
if($r->num_rows==1){
setcookie("isauth", True, time() + (86400 * 30), "/");
setcookie("admin_name", $r->fetch_all()[0][3], time() + (86400 * 30), "/");
header("location:admindashboard");
}
else{
$_SESSION["iserr"]="Username and password are not matching!";
header("location:logadmin");
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$conn->close();
?>