-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
77 lines (68 loc) · 2.84 KB
/
index.php
File metadata and controls
77 lines (68 loc) · 2.84 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
70
71
72
73
74
75
76
77
<?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>
<style>
body{
background-image: url(https://images.prismic.io/dutchlabelshop/ccf6b55b-26af-48be-aca3-b18b21883536_person-weaving-fabric-on-wooden-loom.jpg?auto=compress,format);
background-repeat: no repeat;
background-attachment : fixed;
background-size: 100% 100%;
}
</style>
</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="connect.php" 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="navbar">
<input type="submit" class="btn" name="submit" value="log in" required>
</div>
<div class="links">
Don't have account? <a href="register.php">Sign Up Now</a>
</div>
</form>
</div>
<?php } ?>
</div>
</body>
</html>