-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
110 lines (81 loc) · 2.84 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
require_once "php/db_connect.php";
require_once "php/createtable.php";
//starts sesssion for log in
session_start();
//if logged in push to news feed page
if (isset($_SESSION["username"]))
{
$_user = $_SESSION["username"];
header("Location: postcard.php");
}
else{
session_unset();
session_destroy();
}
//checks if username and pasword entered are part of an account
if (isset($_POST['username']) && isset($_POST['password']))
{
$usern = $_POST['username'];
$passw = $_POST['password'];
$selectStmt = "SELECT * FROM USERS WHERE username='$usern' AND password='$passw'";
$result = $db->query($selectStmt);
if (($result->num_rows) >0)
{
session_start();
$lessMessy = strtolower($usern);
$name = ucfirst($lessMessy);
$_SESSION["username"] = $name;
header("Location: postcard.php");
}
else {
erro();
}
}
/*----------------------clear table--------------------
$dropStmt = 'DROP TABLE `USERS`;';
if($db->query($dropStmt)) {
echo ' <div class="alert alert-success">Table drop successful.</div>' . PHP_EOL;
}
else {
echo ' <div class="alert alert-danger">Table drop failed: (' . $db->errno . ') ' . $db->error . '</div>' . PHP_EOL;
exit();
}
*/
?>
<!-- Latest compiled and minified CSS -->
<html>
<head>
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<link rel="stylesheet" href="css/main.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="postcard.php">
Post-It
</a>
</div>
</div>
</nav>
<?php
function erro()
{
echo "<div class='alert alert-danger' role='alert'>Dang, wrong username or password</div>";
}
?>
<div class="wrapper">
<form class="form-signin" method="post" action="index.php">
<h2 class="form-signin-heading">Please login</h2>
<input type="text" class="form-control" name="username" placeholder="username" required="" autofocus="" />
<input type="password" class="form-control" name="password" placeholder="Password" required=""/>
<a href="index2.php" class="linkz">No login? regester here</a>
<button class="btn btn-lg btn-primary btn-block but" type="submit">Login</button>
</form>
</div>
</body>
</html>