Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include 'header.php';
- include 'functions.php';
- ?>
- <center>
- <table>
- <form method="POST" action="login.php">
- <tr>
- <td>Username : </td><td><input type="text" name="username"/></td>
- </tr>
- <tr>
- <br /> <td>Password :</td><td><input type="password" name="password"/></td>
- </tr>
- <tr>
- <td><input type="submit" name="submit" value="log in"/></td>
- </tr>
- </form>
- </table>
- </center>
- <?php
- //init
- $_POST['username'] = $username;
- $_POST['password'] = $password;
- $_POST['submit'] = $submit;
- // check
- if ($submit)
- {
- connect();
- if ($username && $password)
- {
- $sql = "SELECT username,password FROM users WHERE username = $username";
- $res = mysql_query($sql);
- if (mysql_num_rows($res) > 0)
- {
- $sql2 = "SELECT id FROM users WHERE username = $username AND password = sha1($password)";
- $res2 = mysql_query($sql2);
- if(mysql_num_rows($res2) > 0)
- {
- $row = mysql_fetch_assoc($res2);
- $_SESSION['uid'] = $row['id'];
- echo "You have successfully logged in, $username .<br><br><a href=\"./index.php\">Click here to go to the forums.</a>";
- }
- else
- {
- die ("Username and password combination are incorrect!");
- }
- }
- else
- {
- die("User does not exist!");
- }
- }
- else
- {
- die("Please fill in all fields!");
- }
- }
- ?>
- <?php
- include ('footer.php');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement