-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
98 lines (70 loc) · 2 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
session_start();
require 'dbconfig/config.php';
?>
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<link rel="stylesheet" href="css/stylex.css">
-->
<style>
body
{
background-image: url('https://png.pngtree.com/thumb_back/fw800/background/20190223/ourmid/pngtree-smart-robot-arm-advertising-background-backgroundrobotblue-backgrounddark-backgroundlightlight-image_68405.jpg' );
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% 100%;
}
</style>
</head>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<!-- <body style="background-color:#bdc3c7"> -->
<div id="main-wrapper">
<center>
<h2><strong id="log">Login</strong></h2>
<div class="imgcontainer">
<img src="image/bot_avatar.png" class="avatar"/>
</center>
<form class="myform" action="index.php" method="post">
<div class="inner_container">
<label><b id="un">Username:</b></label><br>
<input name="username" id="us" type="text" class="inputvalues" placeholder="Enter Username here..." required/><br>
<label><b id="pas">Password:</b></label><br>
<input name="password" id="pass" type="password" class="inputvalues" placeholder="Your Password..." required/><br>
<input name="login" type="submit" id="login_btn" value="Login"/><br>
<a href="register.php"><input type="button" id="register_btn" value="Register"/></a> <br>
<a href="admin.php"><input type="button" id="admin_btn" value=" Login as Admin"/></a>
</div>
</form>
<?php
if(isset($_POST['login']))
{
$username=$_POST['username'];
$password=$_POST['password'];
$sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$stmt = $db->prepare($sql);
$stmt->execute();
if( $stmt->rowCount() > 0)
{
// valid
$_SESSION['username']= $username;
header('location:homepage.php');
}
else
{
// invalid
echo '<script type="text/javascript"> alert("Invalid credentials") </script>';
}
}
?>
</div>
</body>
</html>