-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthentication.php
More file actions
52 lines (48 loc) · 1.2 KB
/
Copy pathauthentication.php
File metadata and controls
52 lines (48 loc) · 1.2 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
52
<?php
include 'includes/config.php';
if (isset($_POST['email'])&&isset($_POST['pass'])) {
$conn=mysqli_connect($DBServer, $DBUser, $DBPass, $DBName);
if ($conn->connect_error) {
trigger_error('Database connection failed: ' .
$conn->connect_error, E_USER_ERROR);
}
$em = $_POST['email'];
$pw = $_POST['pass'];
$sql="SELECT * FROM houser where email ='".$em."' AND pass='".$pw."'";
$result = $conn->query($sql);
if($result->num_rows > 0){
while ($row = mysqli_fetch_assoc($result)) {
$_SESSION['valid'] = true;
$_SESSION['timeout'] = time();
$_SESSION['email'] = $row['email'];
$_SESSION['role'] = $row['role'];
$_SESSION['uname'] = $row['name'];
}
if($_SESSION['role']=='user')
{
header('Location: index.php');
}
else if($_SESSION['role']=='houser')
{
header('Location: dashboard.php');
}
else if($_SESSION['role']=='admin')
{
header('Location: admindashboard.php');
}
else
{
header('Location: login.php');
}
}
else
{
?>
<script type="text/javascript">
alert("Invalid Credentails!");
</script>
<?php
header( "refresh:1;url=login.php" );
}
}
?>