-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuccess.php
50 lines (44 loc) · 1.75 KB
/
success.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
46
47
48
49
50
<?php
require('connection.php');
session_start();
$user = trim($_POST['user']);
$upass = trim($_POST['pass']);
$h_pass = MD5($upass);
//create some sql statement
$sql = "SELECT * FROM `admin` WHERE `user` = '" .$user. "' AND `password` = '" . $h_pass . "' ";
$result = $db->query($sql);
//get the number of result based n the sql statement
//check the number of result, if equal to one
//If theres a result
if($result->num_rows > 0){
//store the result to a array and passed to variable found_user
$found_user = mysqli_fetch_array($result);
//fill the result to session variable
$_SESSION['MEMBER_ID'] = $found_user['id'];
$_SESSION['fname'] = $found_user['fname'];
$_SESSION['lname'] = $found_user['lname'];
$_SESSION['position'] = $found_user['Position'];
if ($_SESSION['position']=='ADMIN') {
# code...
?> <script type="text/javascript">
//then it will be redirected to index.php
window.location = "index.php"
</script>
<?php
}else{
?> <script type="text/javascript">
//then it will be redirected to index.php
window.location = "homepage.php"
</script>
<?php
}
}else{
//if theres no result
?> <script type="text/javascript">
alert("Username or Password Not Registered! Contact Your administrator.");
window.location = "login.php";
</script>
<?php
}
$db->close();
?>