Repository navigation
Expand file tree
/
Copy pathindex.php
More file actions
74 lines (63 loc) · 2.36 KB
/
Copy pathindex.php
File metadata and controls
74 lines (63 loc) · 2.36 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
<?php
ob_start();
session_start();
//connection
require("config.php");
// PHP query for login
if (isset($_POST["login"])) {
$userlogin = $_POST["userlogin"];
$userpassword = md5($_POST["userpassword"]);
//Query to check if email address already in use
$query = "SELECT * FROM user WHERE email_address ='$userlogin' OR username='$userlogin' AND password ='$userpassword'";
$result = mysqli_query($conn, $query);
$fetchRow = mysqli_fetch_array($result);
$numRow = mysqli_num_rows($result);
// If email address is not in use
if ($numRow > 0) {
$_SESSION["id"] = $fetchRow["id"];
header("Location:welcome.php");
}
// Error message for email address in use
else {
$message = "<h4 class='card-text alert alert-danger'>Wrong details/h4>";
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Login system using PHP and MySQL">
<meta name="author" content="Ebuka Ohaji">
<meta name="generator" content="Jekyll v4.0.1">
<title>EbuCodes . Login</title>
<!-- CSS -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/css/style.css" rel="stylesheet">
</head>
<body>
<form class="card form-signin" method="POST" enctype="multipart/form-data" action="index.php">
<div class="text-center mb-4">
<img class="mb-4" src="img/logo.png" alt="" width="200" height="200">
<h1 class="h3 mb-3 font-weight-normal">SIGN IN</h1>
<?php
// Display error message
if (isset($message)) {
echo $message;
}
?>
<p class="card-text">Please fill in the details below to login</p>
</div>
<div class="form-label-group">
<input name="userlogin" type="text" class="form-control" placeholder="Email address/Username" required autofocus>
<label>Email address/Username</label>
</div>
<div class="form-label-group">
<input name="userpassword" type="password" id="inputPassword" class="form-control" placeholder="Password" required autofocus>
<label for="inputPassword">Password</label>
</div>
<button name="login" class="btn btn-lg btn-primary btn-block" type="submit">SIGN IN</button>
<p class="mt-5 mb-3 text-muted text-center"></p>
</form>
</body>
</html>