-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
95 lines (87 loc) · 3.19 KB
/
index.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
<?php
session_start();
include_once('dbcon.php');
$error = false;
if(isset($_POST['btn-login'])){
$email = trim($_POST['email']);
$email = htmlspecialchars(strip_tags($email));
$password = trim($_POST['password']);
$password = htmlspecialchars(strip_tags($password));
if(empty($email)){
$error = true;
$errorEmail = 'Please input email';
}elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)){
$error = true;
$errorEmail = 'Please enter a valid email address';
}
if(empty($password)){
$error = true;
$errorPassword = 'Please enter password';
}elseif(strlen($password)< 6){
$error = true;
$errorPassword = 'Password at least 6 character';
}
if(!$error){
$password = md5($password);
$sql = "select * from tbl_users where email='$email' ";
$result = mysqli_query($conn, $sql);
$count = mysqli_num_rows($result);
$row = mysqli_fetch_assoc($result);
if($count==1 && $row['password'] == $password){
$_SESSION['username'] = $row['username'];
header('location: home.php');
}else{
$errorMsg = 'Invalid Username or Password';
}
}
}
?>
<html>
<head>
<title>RUAP</title>
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
</head>
<body>
<div class="container">
</div>
<div class="jumbotron" style="text-align: center;">
<div class="appName">
<h1 class="h2Inline">BASKETBALL SHOT PREDICTION</h1>
<img src="nba.png" class="img-rounded images" width="100" height="100">
</div>
</div>
<div class="container">
<div style="width: 500px; margin: 50px auto;">
<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" autocomplete="off">
<center><h2>Login</h2></center>
<hr/>
<?php
if(isset($errorMsg)){
?>
<div class="alert alert-danger">
<span class="glyphicon glyphicon-info-sign"></span>
<?php echo $errorMsg; ?>
</div>
<?php
}
?>
<div class="form-group">
<label for="email" class="control-label">Email</label>
<input type="email" name="email" class="form-control" autocomplete="off">
<span class="text-danger"><?php if(isset($errorEmail)) echo $errorEmail; ?></span>
</div>
<div class="form-group">
<label for="password" class="control-label">Password</label>
<input type="password" name="password" class="form-control" autocomplete="off">
<span class="text-danger"><?php if(isset($errorPassword)) echo $errorPassword; ?></span>
</div>
<div class="form-group">
<center><input type="submit" name="btn-login" value="Login" class="btn btn-primary"></center>
</div>
<hr/>
<a href="register.php">Register</a>
</form>
</div>
</div>
</body>
</html>