-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoginUser.php
135 lines (122 loc) · 5.17 KB
/
LoginUser.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
require_once("includes/DB.php");
require_once("includes/Functions.php");
require_once("includes/Sessions.php");
if(isset($_SESSION["UserID"])){
$_SESSION["ErrorMessage"] = "You are already logged in!!";
Redirect_to("Blog.php");
}
if (isset($_POST['Submit']))
{
$Name = $_POST['name'];
$Password = $_POST['password'];
if(empty($Name) || empty($Password)){
$_SESSION["ErrorMessage"] = "Please Fill Out All Fields!";
Redirect_to("LoginUser.php");
}
else {
global $ConnectingDB;
$sql = "SELECT * FROM users WHERE name=:NamE AND password=:passworD";
$stmt = $ConnectingDB->prepare($sql);
$stmt->bindValue(":NamE", $Name);
$stmt->bindValue(":passworD", $Password);
$stmt->execute();
$Result = $stmt->rowCount();
$Data = $stmt->fetch();
if($Result==1){
$_SESSION["UserID"] = $Data["id"];
$_SESSION["UserName"] = $Data["name"];
$_SESSION["SuccessMessage"] = "Welcome " . "$Name"." "."! You are Logged In..";
Redirect_to("Blog.php");
}
else{
$_SESSION["ErrorMessage"] = "User Not Found. Please Try Again.";
Redirect_to("LoginUser.php");
}
}
}
?>
<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">
<script src="https://kit.fontawesome.com/d300452dcf.js" crossorigin="anonymous"></script>
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<link href="css/styles.css" rel="stylesheet">
<title>Login Page</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a href="#" class="navbar-brand">YOURVOICE.COM</a>
<button class="navbar-toggler" data-bs-toggle="collapse" data-bs-target="#navbarcollapseBMS">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarcollapseBMS">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a href="RegisterUser.php" class="nav-link">Sign Up</a>
</li>
<li class="nav-item">
<a href="Blog.php" class="nav-link">See Blog Preview</a>
</li>
</ul>
</div>
</div>
</nav>
<header class="bg-dark text-white py-3">
<div class="container">
<div class="row">
<div class="col-md-12">
</div>
</div>
</div>
</header>
<section class="container py-2 mb-4">
<div class="row">
<div class="offset-sm-3 col-sm-6" style="min-height:600px">
<div class="card bg-secondary text-light">
<div class="card-header">
<?php
echo ErrorMessage();
echo SuccessMessage();
?>
<h4>Welcome Back!</h4>
</div>
<div class="card-body bg-dark">
<form class="" action="LoginUser.php" method="post">
<div class="form-group">
<label for="Name"><span class="FieldInfo">Name:</span></label>
<div class="input-group mb-3">
<input class="form-control" type="text" name="name" id="Name">
</div>
</div>
<div class="form-group">
<label for="Password"><span class="FieldInfo">Password:</span></label>
<div class="input-group mb-3">
<input class="form-control" type="password" name="password" id="Password">
</div>
</div>
<input type="submit" name="Submit" class="btn btn-info w-100" value="Login">
</form>
</div>
</div>
</div>
</div>
</section>
<br>
<footer class="bg-dark text-white">
<div class="container">
<div class="row">
<div class="col">
<p class="lead text-center">Website By YourVoice Technologies | 2022 © ---All Rights Reserved. </p>
</div>
</div>
</div>
</footer>
<!-- JavaScript Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
</body>
</html>