-
Notifications
You must be signed in to change notification settings - Fork 7
/
login.php
32 lines (26 loc) · 700 Bytes
/
login.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
<?php
session_start();
include 'includes/conn.php';
if(isset($_POST['login'])){
$voter = $_POST['voter'];
$password = $_POST['password'];
$sql = "SELECT * FROM voters WHERE voters_id = '$voter'";
$query = $conn->query($sql);
if($query->num_rows < 1){
$_SESSION['error'] = 'Cannot find user with that ID. Please try again!';
}
else{
$row = $query->fetch_assoc();
if(password_verify($password, $row['password'])){
$_SESSION['voter'] = $row['id'];
}
else{
$_SESSION['error'] = 'Incorrect password. Please try again!';
}
}
}
else{
$_SESSION['error'] = 'Please provide your Voters ID and Password to continue!';
}
header('location: home.php');
?>