-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php~
executable file
·43 lines (40 loc) · 1.22 KB
/
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
<?php
session_start();
include "config.php";
include "private_functions.php";
include "functions.php";
if(isset($_SESSION['auth']) && $_SESSION['auth'] == 1) {
header('Location: '.$home.'index.php');
}
if(isset($_POST['username']) && isset($_POST['pw'])) {
$pw = hash_pw($_POST['pw']);
$dbh = db_connect($MY_HOST, $MY_DB_PORT, $MY_DB, $DB_USER, $DB_PW);
$res = login($dbh, $_POST['username'],$pw);
if($res['status'] == 1) {
session_login($res['userID']);
header("Location: ".$home."index.php");
} else {
$err_msg = "Invalid login";
echo "hello world";
}
}
?>
<html>
<head>
<title>Login</title>
<?php html_output_head(); ?>
</head>
<body>
<div class="container">
<?php html_nav('login'); ?>
<div class="jumbotron">
<form class="form-signin" role="form" action='login.php' method='POST'>
<h2 class="form-signin-heading">Login</h2>
<h3 class="form-signin-heading"><?php echo $err_msg; ?> </h3>
<input type="text" class="form-control" name='username' placeholder="Username" required autofocus>
<input type="password" class="form-control" name='pw' placeholder="Password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
</form>
</div>
</body>
</html>