Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. <html>
  2.     <body>
  3.     <center>
  4.     <FORM action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  5.     User Name: <input type="text" name="user" maxlength="8"><br>
  6.     Password: <input type="password" name="pass" maxlength="12"><br>
  7.     <input type="submit" name="submit" value="Register">
  8.     </form>
  9.     </body>
  10. <?php
  11. //require db to connect.
  12. require_once('connect.php');
  13.  
  14. //protect from sql injection
  15. $user = $_POST['user'];
  16. $pass = $_POST['pass'];
  17.  
  18.  
  19. //select the table
  20. $result = mysql_query("SELECT * FROM users WHERE $user = 'username' AND $pass = 'password'");
  21.  
  22. //count the rows. register the session, give the error/correct messages. and redirect.
  23. if (mysql_num_rows($result) != 1)
  24.     echo "Please go back and try again.";
  25. else {
  26.     session_register("$user");
  27.     session_register("$pass");
  28.     header('location: index.php');
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement