-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate.php
73 lines (64 loc) · 1.86 KB
/
validate.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!--
File Name: validate.php
Author's Name: Sukhdeep Singh
Web Site Name: My Portfolio
File Description: This page takes the credentials entered by the user in the login.php page
and checks in the database if the credentials are correct and logs the user in otherwise gives
and error message showing that email or password is incorrect
-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Logging In..</title>
<script src="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
</head>
<body>
<?php
$email = $_POST['email'];
//hash the password
$password = sha1($_POST['password']);
//check that the email entered is a proper valid email address
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$conn = mysqli_connect('webdesign4', 'dbxxxxxxxxx', 'xxxxx', 'dbxxxxxxxxx') or die('Error connecting to MySQL server');
$sql = "SELECT id FROM admin WHERE email = '$email' AND password = '$password'";
$result = mysqli_query($conn, $sql) or die('Error querying database.');
$count = mysqli_num_rows($result);
if ($count == 1) {
while ($row = mysqli_fetch_array($result)) {
//access the existing session created by the web server
session_start();
//store the user id in the session object
$_SESSION['user_id'] = $row['id'];
?>
<script>
$.mobile.changePage("business.php#business", {
transition : "slidefade"
});
</script>
<?php
}
} else {
?>
<script>
alert("Access Denied..!! Username or Password is incorrect!!");
$.mobile.changePage("login.php#login", {
transition : "slidefade"
});
</script>
<?php
}
}
else {
?>
<script>
alert("Access Denied..!! Incorrect Email Address..!!");
$.mobile.changePage("login.php#login", {
transition : "slidefade"
});
</script>
<?php
}
?>
</body>
</html>