-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·66 lines (57 loc) · 2.17 KB
/
Copy pathindex.php
File metadata and controls
executable file
·66 lines (57 loc) · 2.17 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
<?php
include("config.php");
session_start();
$error = "";
if($_SERVER["REQUEST_METHOD"] == "POST") {
// username and password sent from form
$myusername = mysqli_real_escape_string($db,$_POST['username']);
$mypassword = mysqli_real_escape_string($db,$_POST['password']);
$sql = "SELECT utorid FROM admin WHERE username = '$myusername' and password = '$mypassword'";
$result = mysqli_query($db,$sql);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$active = $row['active'];
$count = mysqli_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count == 1) {
//session_register("myusername");
$_SESSION['login_user'] = $myusername;
header("location: welcome.php");
}else {
$error = "Your Login Name or Password is invalid";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Welcome to Introduction to Database Login Page</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<div class="container">
<img src="user.png">
<form action = "" method = "post">
<div class="form-input">
<input type="text" name="username"
placeholder = "Enter username">
</div>
<div class="form-input">
<input id="username" type="password" name="password"
placeholder="Enter Password">
</div>
<input type="submit" id="password" onclick="getInfo()" name="submit" value="LOGIN" class="btn-login">
<div style = "font-size:25px; color:#cc0000; margin-top:10px"><?php echo $error; ?></div>
<br>
<a href='registar.php'>Sign Up</a>
</form>
<script src="https://code.jquery.com/jquery-3.3.1.min.js">
</script>
<script>
function getInfo(){
var username = document.getElementById("username")
var password = document.getElementById("password")
}
</script>
</div>
</body>
</html>