Jump to content

Help with Register Page


FireGhozt

Recommended Posts

I'am trying to make the page show the errors in the same page under the register button, but it always disable all the forms and show the error by it self.

 

my code:

<?php

ob_start();

session_start();

include_once "functions.php";

 

connect();

 

if(!$_POST['submit']){

    echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";

    echo "<form method=\"post\" action=\"register.php\">\n";

    echo "<tr><td colspan=\"2\" align=\"center\">Registration Form</td></tr>\n";

    echo "<tr><td>Username</td><td><input type=\"text\" name=\"name\" maxLength=14></td></tr>\n";

    echo "<tr><td>Password</td><td><input type=\"password\" name=\"password\" maxLength=14></td></tr>\n";

    echo "<tr><td>Confirm</td><td><input type=\"password\" name=\"passconf\" maxLength=14></td></tr>\n";

    echo "<tr><td>E-Mail</td><td><input type=\"text\" name=\"email\" maxLength=24></td></tr>\n";

 

    echo "<tr><td>Question</td><td><input type=\"text\" name=\"idnumber\" maxLength=14></td></tr>\n";

    echo "<tr><td>Answer</td><td><input type=\"text\" name=\"phone\" maxLength=14></td></tr>\n";

 

    echo "<form method=\"post\" action=\"captcha.php\">\n";

    echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";

    echo "<tr><td>Type The Letters You See Below Into the Box</td></tr>\n";

    echo "<tr><td align=\"center\"><img src=\"image.php\"></td></tr>\n";

    echo "<tr><td align=\"center\"><input type=\"text\" name=\"image\"></td></tr>\n";

 

    echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Register\"></td></tr>\n";

    echo "</form></table>\n";

}else

{

    $errors = array();

    $name = protect($_POST['name']);

    $password = protect($_POST['password']);

    $confirm = protect($_POST['passconf']);

    $email = protect($_POST['email']);

    $phone = protect($_POST['idnumber']);

    $ownerReply = protect($_POST['phone']);

    $image = $_POST['image'];

 

    if($image == $_SESSION['string']){}else{

    $errors[] = "Wrong Captcha!";

    }ob_end_flush();

 

 

 

        if(!$name){

            $errors[] = "Username is not defined!";

        }

       

        if(!$password){

            $errors[] = "Password is not defined!";

        }

       

        if($password){

            if(!$confirm){

                $errors[] = "Confirmation password is not defined!";

            }

        }

       

        if(!$email){

            $errors[] = "E-mail is not defined!";

        }

 

        if(!$idnumber){

            $errors[] = "Security Question is not defined!";

        }

 

        if(!$phone){

            $errors[] = "Security Answer is not defined!";

        }

       

        if($name){

            if(!ctype_alnum($name)){

                $errors[] = "Username can only contain numbers and letters!";

            }

           

            $range = range(8,14);

            if(!in_array(strlen($name),$range)){

                $errors[] = "Username must be between 8 and 14 characters!";

            }

        }

       

        if($password && $confirm){

            if($password != $confirm){

                $errors[] = "Passwords do not match!";

            }

 

            $range = range(10,14);

            if(!in_array(strlen($password),$range)){

                $errors[] = "Password must be between 10 and 14 characters!";

            }

        }

       

        if($email){

            $checkemail = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";

            if(!preg_match($checkemail, $email)){

                $errors[] = "E-mail is not valid, must be name@server.tld!";

            }

        }

 

        if($idnumber){

            if(!ctype_alnum($phone)){

                $errors[] = "Securty Question can only contain numbers and letters!";

            }

           

            $range = range(8,14);

            if(!in_array(strlen($idnumber),$range)){

                $errors[] = "Securty Question must be between 8 and 14 characters!";

            }

        }

       

        if($phone){

            if(!ctype_alnum($phone)){

                $errors[] = "Securty Answer can only contain numbers and letters!";

            }

           

            $range = range(8,14);

            if(!in_array(strlen($phone),$range)){

                $errors[] = "Securty Answer must be between 8 and 14 characters!";

            }

        }

       

        if($email){

            $sql2 = "SELECT * FROM `account` WHERE `email`='".$email."'";

            $res2 = mysql_query($sql2) or die(mysql_error());

           

                if(mysql_num_rows($res2) > 0){

                    $errors[] = "The e-mail address you supplied is already in use of another user!";

                }

        }

       

        if(count($errors) > 0){

            foreach($errors AS $error){

                echo $error . "<br>\n";

            }

        }else {

            $sql4 = "INSERT INTO `account`

                    (`name`,`password`,`email`,`idnumber`,`phone`)

                    VALUES ('".$name."','".md5($password)."','".$email."','".$idnumber."','".$phone."')";

            $res4 = mysql_query($sql4) or die(mysql_error());

            echo "You have successfully registered with the username <b>".$name."</b> and the password of <b>".$password."</b>!";

        }

}

 

?>

 

Direct link to the register page in case you didn't understand what i mean.

 

http://hebrithco.com/server/bew/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.