Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( !$_SESSION['uid'] ) {
- if ( !$_POST['submit'] ) {
- ?>
- <form action="?page=Login} method="post">
- <table>
- <tr>
- <td>Username</td>
- <td><input type="text" name="username"></td>
- </tr>
- <tr>
- <td colspan="2">
- <input type="sumbit" value="Login" name="sumbit">
- </td>
- </tr>
- </table>
- </form>
- <?php
- } else {
- $username = $_POST['username'];
- $password = md5($_POST['password']);
- $errors = array();
- if ( !$username ) {
- $errors[1] = "The username field is blank.";
- }
- if ( !$password ) {
- $errors[2] = "The Password field is blank.";
- }
- $sql = "SELECT * FROM `users` WHERE `name`='$username'";
- $res = mysql_query($sql) or die(mysql_error());
- $exists = mysql_num_rows($res);
- if ( count($exists) == 0 ) {
- $errors[3] = "The username does not exist.";
- } else {
- $sql = "SELECT * FROM `users` WHERE `name`='$username' AND `password`='$password'";
- $res = mysql_query($sql) or die(mysql_error());
- $exists = mysql_num_rows($res);
- if ( count($exists) == 0 ) {
- $errors[4] = "the username and password do not match.";
- }
- }
- if (count($errors) > 0 ) {
- foreach ( $errors as $errors ) {
- }
- }
- }
- }
- echo "You are already Logged in!";
- include ("pages/Home.php");
- }
- ?>
Add Comment
Please, Sign In to add comment