-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
63 lines (57 loc) · 2.67 KB
/
login.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet">
<link href="style1.css" rel="stylesheet">
<script src="main.js"></script>
<title>ShareTheRide! / Login</title>
<link rel="icon" href="/assets/STR!.svg" type="image/x-icon">
</head>
<body>
<?php
require('users_database_conn.php');
session_start();
if (isset($_POST['username'])) {
$username = stripslashes($_REQUEST['username']);
$username = mysqli_real_escape_string($con, $username);
$password = stripslashes($_REQUEST['password']);
$password = mysqli_real_escape_string($con, $password);
$query = "SELECT * FROM `tbl_users` WHERE username='" . $username . "'
AND password='" . sha1($password) . "'";
$result = mysqli_query($con, $query) or die(mysql_error());
$rows = mysqli_num_rows($result);
if ($rows == 1) {
$_SESSION['username'] = $username;
header("Location: session.php");
} else {
echo '<div style="font-size: 20px; height: 100vh; margin: auto; display: flex; align-items: center; align-self: center; justify-content: center; flex-direction: column;">
<h3 style="letter-spacing: -1px; font-weight: 500; margin-top: -10px;">Looks like you entered something wrong.</h3><br/>
<span><a style="margin-top: -10px; font-weight: 800; color: #00BCD4; text-decoration: none;" href="index.php"><- Go back</a> <strong>or</strong> <a style="margin-top: -10px; font-weight: 800; color: #00BCD4; text-decoration: none;" href="login.php">Try again -></a></span>
</div>';
}
} else {
?>
<form method="post">
<div class="loginui">
<h1>sharetheride!</h1>
<p>Login to your account</p>
<input required type="text" name="username" placeholder="Enter username" />
<input required type="password" name="password" placeholder="Enter password" />
<div class="signuporlogininstead">
<a href="signup">Don't have an account?</a>
</div>
<div class="clearfix">
<a href="index"><button class="gobackbtn" type="button">Go back</button></a>
<button class="signupbtn" type="submit">Next</button>
</div>
</div>
</form>
<?php
}
?>
</body>
</html>