-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthentication.php
More file actions
62 lines (57 loc) · 2.42 KB
/
Copy pathauthentication.php
File metadata and controls
62 lines (57 loc) · 2.42 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
53
54
55
56
57
58
59
60
61
62
<?php
include 'head.php';
include 'body.php';
session_start();
include 'connection.php';
function input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$id = input($_POST["id"]);
$password = input($_POST["pass"]);
/** @var object $con */
$stmt = $con->prepare("SELECT * FROM auth");
$stmt->execute();
$ids = $stmt->get_result();
$res = $ids->fetch_all(MYSQLI_ASSOC);
foreach ($res as $user) {
if ($user['id'] == $id && $user['pass'] != $password) {
echo "<script type='text/javascript'>alert('Check whether your password is correct');
window.location='http://localhost/Juhosi%20Software%20Web%20Development/';
</script>";
}
}
foreach ($res as $user) {
if ($user['id'] != $id && $user['pass'] != $password && $user['type'] == 'admin') {
echo "<script type='text/javascript'>alert('Enter proper ID');
window.location='http://localhost/Juhosi%20Software%20Web%20Development/';
</script>";
}
}
foreach ($res as $user) {
if ($user['id'] != $id && $user['pass'] != $password && $user['type'] == 'cust') {
echo "<script type='text/javascript'>alert('Check whether your ID is registered. Contact Admin!');
window.location='http://localhost/Juhosi%20Software%20Web%20Development/';
</script>";
}
}
foreach ($res as $user) {
if ($user['id'] == $id && $user['pass'] == $password && $user['type'] == 'admin') {
$_SESSION['id'] = $user['id'];
$_SESSION['type'] = $user['type'];
header("location: http://localhost/Juhosi%20Software%20Web%20Development/summary/");
}
}
foreach ($res as $user) {
if ($user['id'] == $id && $user['pass'] == $password && $user['type'] == 'cust') {
$_SESSION['id'] = $user['id'];
$_SESSION['type'] = $user['type'];
header("location: http://localhost/Juhosi%20Software%20Web%20Development/order/");
}
}
}
?>