-
Notifications
You must be signed in to change notification settings - Fork 9
/
login.php
45 lines (40 loc) · 1.15 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
session_start();
require 'config.php';
$conn = connection();
$_SESSION["username"] = $_POST['username'];
$_SESSION["password"] = $_POST['password'];
// session_start();
// echo $_SESSION["username"];
// die;
$sql="SELECT * from users where username='".$_SESSION['username']."'
and password='".$_SESSION['password']."'";
$result=$conn->query($sql);
// foreach ($result as $row) {
// echo $row['user_id']."<br>";
// echo $row['username']."<br>";
// echo $row['password']."<br>";
// }
// die;
if ( $result->rowCount() == 0 ) {
// header("location: login.html");
echo "<script>alert('Incorrect username or password');
document.location='index.html'
</script>";
}
elseif ( $result->rowCount() > 0 ) {
if ($_SESSION["username"]=='admin'&&$_SESSION["password"]=='neola') {
header('location:login.html');
}
elseif (isset($_SESSION["username"])&&isset($_SESSION["password"])) {
foreach ($result as $row) {
echo $row['user_id']."<br>";
echo $row['username']."<br>";
echo $row['password']."<br>";
}
// include 'header.php';
header("location: index.php");
// include 'footer.php';
}
}
?>