-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_login.php
70 lines (57 loc) · 2.23 KB
/
user_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
<?php
require "connection/connect.php";
error_reporting(E_ALL ^ E_NOTICE);
// session_start();
$login = false;
if (isset($_POST['login'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$query = "select * from tb_user where username = '$username' and password = '$password'";
$result = mysqli_query($conn, $query);
$row = mysqli_fetch_array($result);
$count = mysqli_num_rows($result);
if ($count > 0) {
session_start();
$_SESSION['loggedin'] = true;
$_SESSION['username'] = $username;
header('location:' . $siteurl);
} else {
echo "<script> alert('Incorrect username and password'); </script> ";
}
}
?>
<?php
include "Layouts/common_header.php";
?>
<section>
<div class="container f-user">
<div class="f-h-user text-center">
<h1>Login Now</h1>
</div>
<div class="user-form">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" name="userlogin_form" onsubmit="return validateForm()" method="post">
<div class="form-group" id="username">
<label class="control-label" for="username">Username :</label>
<input type="text" class="form-control" placeholder="Enter Username" name="username">
<strong> <span class="formerror"> </span></strong>
</div>
<div class="form-group" id="password">
<label class="control-label" for="password">Password :</label>
<input type="password" class="form-control" placeholder="Enter password" name="password">
<strong> <span class="formerror"> </span></strong>
</div>
<div class="form-group mb-2 mt-2">
<button type="submit" class="btn btn-primary w-25" name="login">Login</button>
</div>
<div class="form-group">
<label>or</label> <br>
<label><a href="<?php $siteurl ?>user_signup.php">don't have an account? Signup.</a></label>
</div>
</form>
</div>
</div>
</section>
<?php
include "Layouts/footer.php";
?>
<script src="js/user_login.js"></script>