Advertisement
Thomas_Smyth

fncregister

Nov 7th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.12 KB | None | 0 0
  1. <?php
  2. //Retrieves variables from Javascript.
  3. $forename = $_POST["forename"];
  4. $surname = $_POST["surname"];
  5. $password = $_POST["password"];
  6. $passwordR = $_POST["passwordR"];
  7.  
  8. if($password == $passwordR){
  9.     try{   
  10.         $LetterCount = 1;
  11.        
  12.         do{
  13.             $username = substr($forename, 0, $LetterCount).".".$surname;
  14.            
  15.             include 'db/openlogindb.php';
  16.             if($DBError == true){
  17.                 $RegisterSuccess = 3;
  18.             }
  19.            
  20.             $accountexist = "
  21.             SELECT * FROM users WHERE username = '".$username."' AND username != 0";
  22.             $result = mysqli_query($conn, $accountexist);
  23.            
  24.             include 'db/closelogindb.php';
  25.            
  26.             $LetterCount += 1;
  27.            
  28.         } while(mysqli_num_rows($result) == 0);
  29.        
  30.         include 'db/openlogindb.php';
  31.         if($DBError == true){
  32.             $RegisterSuccess = 3;
  33.         }
  34.        
  35.         $query = "INSERT INTO users (username, password, rank) VALUES ('".$username."', '".$password."', 1)";
  36.         if (mysqli_query($conn, $query)) {
  37.             $RegisterSuccess = 0;
  38.         }
  39.         else {
  40.             $RegisterSuccess = 2;
  41.         }
  42.         include 'db/closelogindb.php';
  43.     }
  44.     catch(Exception $e){
  45.         $LoginSuccess = 4;
  46.     }
  47. }
  48. else{
  49.     $RegisterSuccess = 1;
  50. }
  51. echo $RegisterSuccess;
  52.  
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement