-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
57 lines (49 loc) · 1.95 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
<?php
include 'config.php';
error_reporting(0);
session_start();
if(isset($_SESSION['username'])){
header("Location: welcome.php");
}
if(isset($_POST['submit'])){
$email = $_POST['email'];
$password = md5($_POST['password']);
$sql = "SELECT * FROM users WHERE email='$email' AND password='$password'";
$result = mysqli_query($conn, $sql);
if($result->num_rows > 0){
$row = mysqli_fetch_assoc($result);
$_SESSION['username'] = $row['username'];
header("Location: welcome.php");
} else {
echo "<script>alert('Woops. Email of password is wrong.')</script>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" integrity="sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<form action="" method="post" class="login-email">
<p class="login-text" style="font-size: 2rem; font-weight: 800;">Login</p>
<div class="input-group">
<input type="email" name="email" placeholder="Email" value="<?php echo $email; ?>" required>
</div>
<div class="input-group">
<input type="password" name="password" placeholder="Password" value="<?php echo $_POST['password']; ?>"required>
</div>
<div class="input-group">
<button name="submit" class="btn">Login</button>
</div>
<p class="login-register-text">Don't have an account? <a href="register.php">Register Here</a>.</p>
</form>
</div>
</body>
</html>