Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Retrieves variables from Javascript.
- $forename = $_POST["forename"];
- $surname = $_POST["surname"];
- $password = $_POST["password"];
- $passwordR = $_POST["passwordR"];
- if($password == $passwordR){
- try{
- $LetterCount = 1;
- do{
- $username = substr($forename, 0, $LetterCount).".".$surname;
- include 'db/openlogindb.php';
- if($DBError == true){
- $RegisterSuccess = 3;
- }
- $accountexist = "
- SELECT * FROM users WHERE username = '".$username."' AND username != 0";
- $result = mysqli_query($conn, $accountexist);
- include 'db/closelogindb.php';
- $LetterCount += 1;
- } while(mysqli_num_rows($result) == 0);
- include 'db/openlogindb.php';
- if($DBError == true){
- $RegisterSuccess = 3;
- }
- $query = "INSERT INTO users (username, password, rank) VALUES ('".$username."', '".$password."', 1)";
- if (mysqli_query($conn, $query)) {
- $RegisterSuccess = 0;
- }
- else {
- $RegisterSuccess = 2;
- }
- include 'db/closelogindb.php';
- }
- catch(Exception $e){
- $LoginSuccess = 4;
- }
- }
- else{
- $RegisterSuccess = 1;
- }
- echo $RegisterSuccess;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement