Advertisement
Guest User

Untitled

a guest
Mar 16th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. <?php ob_start(); ?>
  2. <?php include "database.php";?>
  3.  
  4.  
  5. <?php
  6. // assign values passed in from register.php to the correct values
  7. $username = $_POST['new_name'];
  8. $password = $_POST['new_pass'];
  9. $password2 = $_POST['new_pass2'];
  10. $mobnum = $_POST['new_mobnumber'];
  11.  
  12. // find the length of the values of the functions using the srlen function
  13.  
  14. $userlength = strlen($username);
  15. $mobnumlength = strlen($mobnum);
  16. $passlength = strlen($password);
  17.  
  18. // create a query that checks to see if the username already exists
  19. $query = "SELECT * FROM `members` WHERE `User`='$username'";
  20. $usercheck = $mysqli->query($query);
  21.  
  22.  
  23. // create a selection statement that registers the account only if all the conditions have been met
  24. if ($userlength <16 && $passlength <17 && $password == $password2 && $mobnumlength <12 && is_numeric($mobnum) == true && !$row = $usercheck->fetch_assoc()) {
  25. // create a query to insert the new data into the database
  26. $query= ("INSERT INTO `members`(`User`, `Password`, `MobNumb`) VALUES ('$username', '$password', '$mobnum')");
  27. $mysqli->query($query);
  28.  
  29. ob_end_clean();
  30. header("Location: registeredaccount.php");
  31. }
  32. else{
  33.  
  34. ob_end_clean();
  35. header("Location: registererror.php");
  36. }
  37. ob_end_flush();
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement