-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
89 lines (49 loc) · 1.61 KB
/
index.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
error_reporting(0);
include("connection.php");
//grab values email and password from login form
$login_email = mysqli_real_escape_string($dbc, trim($_POST['login_email']));
$login_password = mysqli_real_escape_string($dbc, trim($_POST['login_password']));
//create the query and number of rows returned from the query
$query = mysqli_query($dbc, "SELECT * FROM users WHERE email='".$login_email."'");
$numrows = mysqli_num_rows($query);
if($_SERVER['REQUEST_METHOD'] == 'POST'){
//create condition to check if there is 1 row with that email
if($numrows != 0){
//grab the email and password from that row returned before
while($row = mysqli_fetch_array($query)){
$dbemail = $row['email'];
$dbpass = $row['password'];
$dbfirstname = $row['first_name'];
}
//create condition to check if email and password are equal to the returned row
if($login_email==$dbemail){
if($login_password==$dbpass){
echo "<p>Welcome ".$dbfirstname.", you are in!</p>";
include ("navbar.php");
}else{
echo "your password is incorrect!";
}
}else{
echo "your email is incorrect!";
}
}else{
echo "Invalid credentials! If you are not registered please register below...";
}
}else{
echo "<h3> Please Login to enter Web Project 1! </h3>";
}
?>
<html>
<head>
<title></title>
</head>
<body>
<form method="post" action="login.php">
<p>Email:<input type="text" name="login_email" maxlength="50"/></p>
<p>Password:<input type="password" name="login_password" maxlength="50"/></p>
<p><input type="submit" value="Login" /></p>
</form>
<a href="newuser.php">Register Here</a>
</body>
</html>