-
Notifications
You must be signed in to change notification settings - Fork 0
/
loginsystem.php
37 lines (34 loc) · 1.14 KB
/
loginsystem.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
37
<?php
session_start();
$username = $_POST['loginusername'];
$password = $_POST['loginpassword'];
$conn = mysqli_connect('localhost', 'root', '', 'DollarFinder');
if(mysqli_connect_errno()) {
echo "Failed to Connect: " . mysqli_connect_error();
}
$query = "select * from users";
$sql = mysqli_query($conn, $query);
if($sql == false) {
echo "Failed Database";
} else {
$userFound = false;
while($row = mysqli_fetch_array($sql, MYSQLI_ASSOC)) {
if($username == $row['username']) {
$userFound = true;
if(password_verify($password, $row['password'])) {
if($row['activated'] == 1) {
$_SESSION['id'] = "logged";
$_SESSION['usern'] = $row['username'];
header("location:index.php");
}
} else {
$_SESSION['password'] = "false";
header("location: login.php");
}
}
}
if($userFound == false) {
echo "No such user Found";
}
}
?>