-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckauth.php
More file actions
52 lines (35 loc) · 1.3 KB
/
Copy pathcheckauth.php
File metadata and controls
52 lines (35 loc) · 1.3 KB
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
50
51
<?php include 'dbconn.php';?>
<?php
if(!empty($_POST['username']) && !empty($_POST['password'])) {
$user=mysqli_real_escape_string($conn,$_POST['username']);
$pass=mysqli_real_escape_string($conn,$_POST['password']);
$query=mysqli_prepare($conn,"SELECT * FROM authoriser WHERE username=?"." AND password=?");
mysqli_stmt_bind_param($query,'ss',$user,$pass);
mysqli_stmt_execute($query);
$result=mysqli_stmt_get_result($query);
$numrows=mysqli_num_rows($result);
if($numrows==1)
{
$row=mysqli_fetch_assoc($result);
$dbusername=$row['username'];
$dbpassword=$row['password'];
$authoriser=$row['id'];
if($user == $dbusername && $pass == $dbpassword)
{
session_start();
$_SESSION['sess_user']=$user;
$_SESSION['authid']=$authoriser;
/* Redirect browser */
header("Location: authcheck.php");
}
}
else {
echo "<script>alert('Invalid Login Credentials');
window.location.href='authorizer.php';</script>";
}
}
else {
echo "<script>alert('All fields are required!');
window.location.href='authorizer.php';</script>";
}
?>