Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Check to see if the form has been submitted
- if(isset($_POST['submit'])){
- //protect and then add the posted data to variables
- $username = protect($_POST['username']);
- $password = protect($_POST['password']);
- $password2 = protect($_POST['password2']);
- $email = protect($_POST['email']);
- $permisson = protect ($_POST['permission']);
- $agree = protect ($_POST['agree']);
- //check to make sure they agree to TOS
- if(!$agree){
- echo "You must agree to the Terms of Service to sign up";
- }else{
- //check to see if any of the boxes were not filled in
- if(!$username){
- //if any weren't display the error message
- echo "<center>You need to fill in a Username!</center>";
- }else{
- if(!$password){
- //if any weren't display the error message
- echo "<center>You need to fill in a password!</center>";
- }else{
- if(!$password2){
- //if any weren't display the error message
- echo "<center>You need to fill in the conformation password!</center>";
- }else{
- if(!$email){
- //if any weren't display the error message
- echo "<center>You need to enter an email adress!</center>";
- }else{
- if(!$permission){
- //if any weren't display the error message
- echo "<center>Select if you are an artist or not!</center>";
- }else{
- //if all were filled in continue checking
- //Check if the wanted username is more than 32 or less than 3 charcters long
- if(strlen($username) > 32 || strlen($username) < 3){
- //if it is display error message
- echo "<center>Your <b>Username</b> must be between 3 and 32 characters long!</center>";
- }else{
- //if not continue checking
- //select all the rows from out users table where the posted username matches the username stored
- $res = mysql_query("SELECT * FROM `users` WHERE `username` = '".$username."'");
- $num = mysql_num_rows($res);
- //check if theres a match
- if($num == 1){
- //if yes the username is taken so display error message
- echo "<center>The <b>Username</b> you have chosen is already taken!</center>";
- }else{
- //otherwise continue checking
- //check if the password is less than 5 or more than 32 characters long
- if(strlen($password) < 5 || strlen($password) > 32){
- //if it is display error message
- echo "<center>Your <b>Password</b> must be between 5 and 32 characters long!</center>";
- }else{
- //else continue checking
- //check if the password and confirm password match
- if($password != $password2){
- //if not display error message
- echo "<center>The <b>Password</b> you supplied did not math the confirmation password!</center>";
- }else{
- //otherwise continue checking
- //Set the format we want to check out email address against
- $checkemail = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
- //check if the formats match
- if(!preg_match($checkemail, $email)){
- //if not display error message
- echo "<center>The <b>E-mail</b> is not valid, must be name@server.tld!</center>";
- }else{
- //if they do, continue checking
- //select all rows from our users table where the emails match
- $res1 = mysql_query("SELECT * FROM `users` WHERE `email` = '".$email."'");
- $num1 = mysql_num_rows($res1);
- //if the number of matchs is 1
- if($num1 == 1){
- //the email address supplied is taken so display error message
- echo "<center>The <b>E-mail</b> address you supplied is already taken</center>";
- }else{
- //finally, otherwise register there account
- //insert the row into the database
- //first secure password with md5()
- $password = md5($password);
- $res2 = mysql_query("INSERT INTO `users` (`username`, `password`, `email`, `permission`) VALUES('".$username."','".$password."','".$email."','".$permission."')");
- //display the success message
- echo "<center>You have successfully registered, please login to access your account!</center>";
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement