-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsign_in.php
64 lines (62 loc) · 2.57 KB
/
sign_in.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
<html lang="en">
<head>
<meta charset="utf-8">
<link href="style.css" rel="stylesheet">
<title>671BookStore</title>
<script type='text/javascript' src="scripts.js"></script>
</head>
<body onload="showMenu()">
<h1>
671 BookStore
</h1>
<div class = "menu" style="margin-bottom: 2em;">
<center>
<a href=".">Home</a>
<a href="books.php">Books</a>
<a href="search.php">Search</a>
<a id="signin" style='display:none' href="sign_in.php">Sign in</a>
<a id="register" style='display:none' href="register.php">Register</a>
<a id="myaccount" style='display:none' href="myaccount.php">My Account</a>
<a id="admin" style='display:none' href="admin.php">Admin</a>
<a id="signout" style='display:none' onclick="signout()" href="index.php">Sign Out</a>
</center>
<center>
<form method="POST">
<h3>Username</h3>
<input type="text" name="username" maxlength="20">
<h3>Password</h3>
<input type="password" name="password" maxlength="20">
<br>
<br>
<input type="submit" value="Sign in" name="SignIn">
</form>
<?php
$con=mysqli_connect("dbproject.saadmtsa.club","root","password","dbproject");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if (isset($_POST['SignIn']))
{
$username = $_POST['username'];
$password = $_POST['password'];
$myquery = "SELECT count(*),sum(type) FROM `users` WHERE `username` = '$username' AND `password` = MD5('$password');";
$result = mysqli_query($con,$myquery);
while($row = mysqli_fetch_row($result))
{
if($row[0] == '1')
{
echo "<script> signin('$username')</script>";
echo '<br>Successfully logged in!';
}
else
{
echo '<br>Wrong credentials!';
break;
}
}
}
?>
</center>
</body>
</html>