-
Notifications
You must be signed in to change notification settings - Fork 73
/
login.php
90 lines (68 loc) · 2.65 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
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
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>login</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<link rel='stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900|RobotoDraft:400,100,300,500,700,900'>
<link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css'>
<link rel="stylesheet" href="css/login.css">
<style type="text/css">
#buttn{
color:#fff;
background-color: #ff3300;
}
</style>
</head>
<body>
<?php
include("connection/connect.php"); //INCLUDE CONNECTION
error_reporting(0); // hide undefine index errors
session_start(); // temp sessions
if(isset($_POST['submit'])) // if button is submit
{
$username = $_POST['username']; //fetch records from login form
$password = $_POST['password'];
if(!empty($_POST["submit"])) // if records were not empty
{
$loginquery ="SELECT * FROM users WHERE username='$username' && password='".md5($password)."'"; //selecting matching records
$result=mysqli_query($db, $loginquery); //executing
$row=mysqli_fetch_array($result);
if(is_array($row)) // if matching records in the array & if everything is right
{
$_SESSION["user_id"] = $row['u_id']; // put user id into temp session
header("refresh:1;url=index.php"); // redirect to index.php page
}
else
{
$message = "Invalid Username or Password!"; // throw error
}
}
}
?>
<!-- Form Mixin-->
<!-- Input Mixin-->
<!-- Button Mixin-->
<!-- Pen Title-->
<div class="pen-title">
<h1>Login Form</h1>
</div>
<!-- Form Module-->
<div class="module form-module">
<div class="toggle">
</div>
<div class="form">
<h2>Login to your account</h2>
<span style="color:red;"><?php echo $message; ?></span>
<span style="color:green;"><?php echo $success; ?></span>
<form action="" method="post">
<input type="text" placeholder="Username" name="username"/>
<input type="password" placeholder="Password" name="password"/>
<input type="submit" id="buttn" name="submit" value="login" />
</form>
</div>
<div class="cta">Not registered?<a href="registration.php" style="color:#f30;"> Create an account</a></div>
</div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
</body>
</html>