Version 1 of DB auth. Only works with user/login.php for now.
This commit is contained in:
parent
c8706fc865
commit
ed0efd68a9
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +0,0 @@
|
||||
index.php
|
16
includes/login_form.inc
Normal file
16
includes/login_form.inc
Normal file
@ -0,0 +1,16 @@
|
||||
<form action="login.php" method="post">
|
||||
<input type="hidden" name="do" value="authenticate">
|
||||
|
||||
<table border=0>
|
||||
<tr>
|
||||
<td><strong>Username</strong></td>
|
||||
<td><input type="text" name="username" size="20" maxlength="20"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Password</strong></td>
|
||||
<td><input type="text" name="password" size="20" maxlength="20"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2 align="center"><input type="submit" value="Login"></td>
|
||||
</tr>
|
||||
</table>
|
32
user/login.php
Normal file
32
user/login.php
Normal file
@ -0,0 +1,32 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Login</title>
|
||||
</head>
|
||||
<?php
|
||||
if ( $_POST['do'] == "authenticate") {
|
||||
# require "../includes/config.php";
|
||||
require "../includes/dbconnect.php";
|
||||
|
||||
$sql = "SELECT id FROM users WHERE username='$_POST[username]' and password=PASSWORD('$_POST[password]')";
|
||||
$result = mysql_query($sql) or die (mysql_error());
|
||||
|
||||
echo mysql_num_rows($result);
|
||||
|
||||
if (mysql_num_rows($result) == 1) {
|
||||
echo "<p>You are a valid user!<br />";
|
||||
echo "Your username is $_POST[username]<br />";
|
||||
echo "Your password is $_POST[password]</p>";
|
||||
include("login_form.inc");
|
||||
} else {
|
||||
unset($_POST['do']);
|
||||
echo "<p>You are not authorized. Please try again.</p>";
|
||||
include("login_form.inc");
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
include("login_form.inc");
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
16
user/login_form.inc
Normal file
16
user/login_form.inc
Normal file
@ -0,0 +1,16 @@
|
||||
<form action="login.php" method="post">
|
||||
<input type="hidden" name="do" value="authenticate">
|
||||
|
||||
<table border=0>
|
||||
<tr>
|
||||
<td><strong>Username</strong></td>
|
||||
<td><input type="text" name="username" size="20" maxlength="20"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Password</strong></td>
|
||||
<td><input type="text" name="password" size="20" maxlength="20"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2 align="center"><input type="submit" value="Login"></td>
|
||||
</tr>
|
||||
</table>
|
Loading…
x
Reference in New Issue
Block a user