Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. <?
  2. /**
  3.  * Process.php
  4.  */
  5.  
  6. include("database.php");
  7.  //process form
  8. // really shouldnt use posts but u can always sanitize them
  9.  
  10. $subuser = $_POST["username"];
  11. $subfirst = $_POST["firstname"];
  12. $subsurname = $_POST["surname"];
  13. $subpassword = $_POST["password"];
  14.  
  15. function usernameTaken($username) && passwordTaken($password){
  16.       $q = "SELECT username && password FROM ".TBL_USERS." WHERE username = '$username' && password = '$password'";
  17.       $result = mysql_query($q);
  18.       return (mysql_num_rows($result) > 0);
  19.    }
  20.  
  21. //check username is taken
  22. //username is not in use so we add it to database
  23. if (usernameTaken($subuser) && passwordTaken($subpassword)) == 0 ) {
  24.  
  25.     $q = mysql_query ("INSERT INTO information (username, firstname, surname, password) VALUES ('$subuser', '$subfirst', '$subsurname', '$subpassword')");  echo mysql_error();
  26.     $success = 1;
  27.     if ($success == 1) { echo "User ".$subuser." And "$subpassword" Added"; }
  28.     }
  29.  
  30. //username is in use so we tell user and re-display form */
  31. else if (usernameTaken($subuser) && passwordTaken($subpassword)) > 0 ) {
  32.     echo "User ".$subuser." already exists, choose another username";
  33.     header('Refresh:3; URL= informationform.php');
  34.         }  
  35. ?>
  36.  
  37.  
  38. <a href="display_users.php">Show Users</a><br / >
  39. <a href="informationform.php">Add a new user</a>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement