-
Notifications
You must be signed in to change notification settings - Fork 4
/
login_action.php
34 lines (32 loc) · 1.04 KB
/
login_action.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
<?php
session_start();
include "connection.php";
if(isset($_POST['login'])) {
$username = $_POST["username"];
$password = $_POST["password"];
$username = addslashes($username);
$password = addslashes($password);
$username = mysqli_real_escape_string($con,$username);
$password = mysqli_real_escape_string($con,$password);
$sql = mysqli_query($con, 'SELECT * FROM loginusers WHERE username="'.$_POST['username'].'" AND password="'.md5($_POST['password']).'" AND status="ACTIVE" ' );
if (mysqli_num_rows($sql) >0 ) {
$member = mysqli_fetch_assoc($sql);
$_SESSION['SESS_NAME'] = $member['username'];
$_SESSION['SESS_RANK'] = $member['rank'];
if($member['rank']=='administrator'){
header("location: admin.php");
}
else if($member['rank']=='voter'){
header("location: voter.php");
}
}
else {
$error = "<center><h4><font color='#FF0000'>Incorrect Username or Password</h4></center></font>";
include "login.php";
}
}
else {
$error = "<center><h4><font color='#FF0000'>Invalid Username or Password</h4></center></font>";
include "login.php";
}
?>