-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.php
85 lines (61 loc) · 1.71 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
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
<html><head><title>Site | Login</title>
<?
include 'login_data.php';
include 'connect_to_db.php';
?>
</head>
<body>
<?
if(isset($_POST['submit'])) {
$uname = $_POST['uname'];
$pword = $_POST['pword'];
if($uname != NULL && $pword != NULL) {
$fix_uname = urlencode($uname);
$md5_pword = md5($pword);
//echo $fix_uname;
//echo "<br>";
//echo $md5_pword;
//echo "<br>";
$query = "select * from users where username='$fix_uname' and password='$md5_pword'";
$result = mysql_query($query);
//echo mysql_numrows($result);
if (mysql_numrows($result) == 1) {
echo "<div style='background:#eeeeee;'>Redirecting...</div>";
$sessionid = "SE_".rand(0,90909090)."Er67GHG_ssdw".rand(0,90909090)."4736GEr67G_".rand(0,90909090)."E4trdsa_".rand(0,909090);
$query = "Insert into logged_in values ('','$sessionid','$fix_uname','0','1')";
$result = mysql_query($query);
echo "<script type=\"text/javascript\">";
echo "var url='member/home.php?sid=$sessionid';";
echo "document.location.href=url;";
echo "</script>";
} else {
echo "<div style='background:#eeeeee;'>Wrong username/password.</div>";
}
}
}
?>
<h2>Login Form</h2>
<form method="POST">
<table>
<tr>
<td>
Username:
</td>
<td>
<input type="text" name="uname" size="25" value=<?php echo $_POST['uname']; ?>>
</td>
<td><i>Forgot my username!</i></td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<input type="text" name="pword" size="25" value=<?php echo $_POST['nothing']; ?>>
</td>
<td><i>Forgot my password!</i></td>
</tr>
</table>
<input type="submit" value="Login" name="submit">
</form>
</body>