Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //take inputs from register.html
- $userNameInput = $_POST['Name'];
- $userEmailInput = $_POST['Email'];
- $userPasswordInput = $_POST['Password'];
- $userWaterInput = $_POST['Water'];
- $userImageInput = $_POST['Image'];
- $userLocationInput = $_POST['Location'];
- $userCourseInput = $_POST['Course'];
- $codeID = rand(100, 999);
- //database connection jazz
- $username="webuser";
- $password="";
- $database="assassin";
- //connection line
- $connected = mysql_connect(localhost,$username,$password);
- if (!$connected) {
- die('Could not connect: ' . mysql_error());
- }
- //selects database
- mysql_select_db($database, $connected) or die('Unable to select database: ' . $mysql_error());
- //checks if UID is taken
- $checker = 1;
- while($checker==1):
- $codeidcheck = mysql_select("SELECT name FROM users WHERE codeid = ".$codeID);
- if(!$codeidcheck) break;
- else $codeID = rand(100, 999);
- endwhile;
- $query = "INSERT INTO users (codeid,name,email,password,water,image,location,course) VALUES ('$codeID','$userNameInput','$userEmailInput','$userPasswordInput','$userWaterInput','$userImageInput','$userLocationInput','$userCourseInput')";
- $result = mysql_query($query);
- if ($result)
- {
- echo "Data entered!";
- echo "Your CodeID (login) is";
- print $codeID;
- }
- else echo "Failed!";
- //closes database connection
- mysql_close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement