Help with Register Page

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.

<?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 “

<td colspan=“2” align=“center”>Registration Form\n”;
echo “ Username <input type=“text” name=“name” maxLength=14> \n”;
echo “ Password <input type=“password” name=“password” maxLength=14> \n”;
echo “ Confirm <input type=“password” name=“passconf” maxLength=14> \n”;
echo “ E-Mail <input type=“text” name=“email” maxLength=24> \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 [email protected]!";
        }
    }

    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/

Sponsor our Newsletter | Privacy Policy | Terms of Service