chavdave26

login.php

Oct 15th, 2012
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. <?php
  2. /*
  3. -- To Do --
  4. * Change values in the connection
  5. * Change field & table names in the query
  6. */
  7. session_start();
  8. $db = new mysqli("localhost", "d290986_chav", "courtney1232008", "d290986_mywebsite");
  9. if( isset($_POST) ) {
  10. /*
  11. -- To Do --
  12. * Encrypt password
  13. */
  14. $exist = $db->query("SELECT `userid`,`username` FROM `login` WHERE `username`='{$_POST['username']}' AND `password`='{$_POST['pass']}'");
  15. if( $exist->num_rows ) {
  16. $r = $exist->fetch_array(MYSQLI_ASSOC);
  17. $_SESSION['loggedin'] = 1;
  18. $_SESSION['user'] = $r['user'];
  19. echo 'You\'ve loggedin!' $r['username'] . PHP_EOL;
  20. } else {
  21. echo 'Can\'t find you!' . PHP_EOL;
  22. }
  23. }
  24. ?>
  25. <form action="" method="post">
  26. Username <input type="text" name="username" length="5" size="5" maxlength="20" /> <br />
  27. Password <input type="password" name="pass" length="5" size="5" maxlength="25" /> <br />
  28. <input type="submit" value="login" />
  29. </form>
Advertisement
Add Comment
Please, Sign In to add comment