-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
69 lines (60 loc) · 2.41 KB
/
index.php
File metadata and controls
69 lines (60 loc) · 2.41 KB
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
<?php
session_start();
?>
<!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">
<link rel="stylesheet" href="style/style.css">
<title>Login</title>
</head>
<body>
<div class="container">
<div class="box form-box">
<?php
include("php/config.php");
if(isset($_POST['submit'])){
$email = mysqli_real_escape_string($con,$_POST['email']);
$password = mysqli_real_escape_string($con,$_POST['password']);
$result = mysqli_query($con,"SELECT * FROM users WHERE Email='$email' AND Password='$password' ") or die("Select Error");
$row = mysqli_fetch_assoc($result);
if(is_array($row) && !empty($row)){
$_SESSION['valid'] = $row['Email'];
$_SESSION['username'] = $row['Username'];
$_SESSION['age'] = $row['Age'];
$_SESSION['id'] = $row['Id'];
}else{
echo "<div class='message'>
<p>Wrong Username or Password</p>
</div> <br>";
echo "<a href='index.php'><button class='btn'>Go Back</button>";
}
if(isset($_SESSION['valid'])){
header("Location: home.php");
}
}else{
?>
<header>Login</header>
<form action="" method="post">
<div class="field input">
<label for="email">Email</label>
<input type="text" name="email" id="email" autocomplete="off" required>
</div>
<div class="field input">
<label for="password">Password</label>
<input type="password" name="password" id="password" autocomplete="off" required>
</div>
<div class="field">
<input type="submit" class="btn" name="submit" value="Login" required>
</div>
<div class="links">
Don't have account? <a href="register.php">Sign Up Now</a>
</div>
</form>
</div>
<?php } ?>
</div>
</body>
</html>