-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
42 lines (35 loc) · 1.1 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
<?php
require_once 'header.php';
echo "<div class ='main'><h3>please enter your details to log in</h3>";
$error =$user=$pass="";
if(isset($_POST['user']))
{
$user=sanitizeString($_POST['user']);
$pass=sanitizeString($_POST['pass']);
if($user ==""||$pass=="")
$error ="Not all fields were entered<br>";
else{
$result =queryMysql("SELECT user,pass FROM members WHERE user ='$user' AND pass='$pass'");
if($result-> num_rows == 0)
{
$error="<span class='error'>Username/Password invalid</span><br><br>";
}
else {
$_SESSION['user']=$user;
$_SESSION['pass']=$pass;
die("You are now logged in.Please <a href='members.php?view=$user'>clic here</a> to continue.<br><br>");
}
}
}
echo <<<_END
<form method ='post' action ='login.php'>$error
<span class='fieldname'>Username</span><input type ='text' maxlength='16' name='user' value='$user'><br>
<span class='fieldname'>Password</span><input type ='password' maxlength='16' name='pass' value='$pass'><br>
_END;
?>
<br>
<span class='fieldname'> </span>
<input type='submit'value ='Login'>
</form><br></div>
</body>
</html>