Hello,

I am having some trouble with my registration form.

For some reason when i launch my registration for wheter it be on localhost or webhost nothing is displaying on the page.

I get no errors or anything and i cannot detect what is wrong with the script i made.

I am a newbie so if someone could help me and tell me what the problem maybe is?

It is a regsitration form that validates users information, once validation checks have been made and once a check on the database has been done to make sure there are no other username and emal address already exists it is to send the info to the DB.

Problem is nothing is showing, not even the form, i just get a blank white page. I have gone over it so many times and still cannot figure out the problem.

Ok here is my code.

<?php include("db_connect.php"); // Database Connection ?>

<?php

if (isset($_POST['submitted'])) { // Handle the form.

// Website Name
$site = "My Website";

// Get User Data From Form
$username = htmlspecialchars( stripslashes( strip_tags($_POST['username'] ) ) );
$first_name = htmlspecialchars( stripslashes( strip_tags($_POST['first_name'] ) ) );
$last_name = htmlspecialchars( stripslashes( strip_tags($_POST['last_name'] ) ) );
$email = htmlspecialchars( strtolower( stripslashes( strip_tags($_POST['email1'] ) ) ) );
$email_2 = htmlspecialchars( strtolower( stripslashes( strip_tags($_POST['email2'] ) ) ) );
$password = htmlspecialchars( trim($_POST['pass1'] ) );
$password_2 = htmlspecialchars( trim($_POST['pass2'] ) );
$date_time = date('l F Y, g:i:s: A');


// Form Validation

if ( empty ($_POST['username'] ) ) { // Check if username field is empty. If it is tell them
	echo "<font color=\"#FF3F00\" face=\"Verdana, Geneva, sans-serif\"><p>Please Enter a Username</p></font>";
    $err++;
}

if ( empty ($_POST['first_name'] ) ) { // Check if first name field is empty. If it is tell them
	echo "<font color=\"#FF3F00\" face=\"Verdana, Geneva, sans-serif\"><p>Please Enter Your First Name</p></font>";
    $err++;
}

if ( empty ($_POST['last_name'] ) ) { // Check if last name field is empty. If it is tell them
	echo "<font color=\"#FF3F00\" face=\"Verdana, Geneva, sans-serif\"><p>Please Enter Your Last Name</p></font>";
    $err++;
}

if ( empty ($_POST['email1'] ) ) { // Check if email field is empty. If it is tell them
	echo "<font color=\"#FF3F00\" face=\"Verdana, Geneva, sans-serif\"><p>Please Enter your email address</p></font>";
    $err++;
}

if ( empty ($_POST['email2'] ) ) { // Check if confirm email field is empty. If it is tell them
	echo "<font color=\"#FF3F00\" face=\"Verdana, Geneva, sans-serif\"><p>Please Confirm your email address</p></font>";
    $err++;
}

if ($_POST['email1'] != $_POST['email2']) { // Check if both emails match. If they are not the same tell them
	echo "<font color=\"#FF3F00\" face=\"Verdana, Geneva, sans-serif\"><p>Your Email address does not match</p></font>";
    $err++;
}
if ( empty ($_POST['pass1'] ) ) { // Check if password field is empty. If it is tell them
	echo "<font color=\"#FF3F00\" face=\"Verdana, Geneva, sans-serif\"><p>Please Enter a Password</p></font>";
    $err++;
}

if ( empty ($_POST['pass2'] ) ) { // Check if confirm password field is empty. If it is tell them
	echo "<font color=\"#FF3F00\" face=\"Verdana, Geneva, sans-serif\"><p>Please Confirm Your Password</p></font>";
    $err++;
}

if ($_POST['pass1'] != $_POST['pass2']) { // Check if both password match. If they are not the same tell them
	echo "<font color=\"#FF3F00\" face=\"Verdana, Geneva, sans-serif\"><p>Your Paswords do not match</p></font>";
    $err++;
}

$testuser = mysql_query("SELECT * FROM userinformation WHERE `username` = '$username'");
if( @mysql_num_rows( $testuser ) > 0 ) {
    echo "<font color=\"#FF3F00\" face=\"Verdana, Geneva, sans-serif\"><p>That username is already in use.</p></font>";    
    $err++;
}

$testemail = mysql_query("SELECT * FROM userinformation WHERE `email` = '$email'");
if( @mysql_num_rows( $testemail ) > 0 ) {
    echo "<font color=\"#FF3F00\" face=\"Verdana, Geneva, sans-serif\"><p>That email address is already in use.</p></font>";    
    $err++;
}

// If user passes Validation give them a nice little message and send then an email with login details :)
if( $err == 0 ) {

$query = "INSERT INTO userinformation (username, first_name, last_name, email, password, date_time) VALUES ('$username', '$first_name', '$last_name', '$email', '$password', '$date_time')";

// Details to be sent with email
$subject = "Your Login Details for $site";
$headers = "From: $site \r\n";
$headers .= "content-type: text/html \r\n";
$message .= '<h1>Thank-you for registering with us at $site</h1>';
$message .= '<p>Below is your Username and Password you signed up with. Please keep these safe incase you forget them.</p>';
$message .= '<p>Username: '.$username.'</p>';
$message .= '<p>Password: '.$_POST['pass1'].'</p>';       
$message .= '<p>Thanks as always,</p>';
$message .= '<p>$site</p>';

// Mail the user
mail( $email, $subject, $message, $headers );
// Dispplay message
echo "<font color=\"#007FAA\" face=\"Arial, Helvetica, sans-serif\"><p>Thank you <b>$first_name $last_name!</b> You have successfully registered an account with us at <b>$site</b> An email with your login details has been sent to <b>$email</b>.</p></font>";
} else {
    ?>
<h1><font color="#007FAA" face="Verdana, Geneva, sans-serif">Register</font></h1>
<form action="register.php" method="post">
    <fieldset>
    
    <p><b><font color="#007FAA" face="Arial, Helvetica, sans-serif">*Username:</font></b> <input type="text" name="username" size="20" maxlength="20" value="<?php if (isset($_POST["username"])) { echo htmlspecialchars($_POST["username"]); } ?>" /></p>
    
    <p><b><font color="#007FAA" face="Arial, Helvetica, sans-serif">*First Name:</font></b> <input type="text" name="first_name" size="20" maxlength="40" value="<?php if (isset($_POST["first_name"])) { echo htmlspecialchars($_POST["first_name"]); } ?>" /></p>
    
    <p><b><font color="#007FAA" face="Arial, Helvetica, sans-serif">*Last Name:</font></b> <input type="text" name="last_name" size="20" maxlength="50" value="<?php if (isset($_POST["last_name"])) { echo htmlspecialchars($_POST["last_name"]); } ?>" /></p>
    
    <p><b><font color="#007FAA" face="Arial, Helvetica, sans-serif">*Email Address:</font></b> 
    <input type="text" name="email1" size="30" maxlength="50" value="<?php if (isset($_POST["email1"])) { echo htmlspecialchars($_POST["email1"]); } ?>" /></p>
    <p><b><font color="#007FAA" face="Arial, Helvetica, sans-serif">*Confirm Email Address:</font></b> 
    <input type="text" name="email2" size="30" maxlength="50" value="<?php if (isset($_POST["email2"])) { echo htmlspecialchars($_POST["email2"]); } ?>" /></p>
    
        
    <p><b><font color="#007FAA" face="Arial, Helvetica, sans-serif">*Password:</font></b> 
      <input type="password" name="pass1" size="20" maxlength="20" /> </p>
    <p><b><font color="#007FAA" face="Arial, Helvetica, sans-serif">*Confirm Password:</font></b> <input type="password" name="pass2" size="20" maxlength="20" /></p>
    </fieldset>
    
    <div align="center"><input type="submit" name="submit" value="Register" /></div>
        <input type="hidden" name="submitted" value="TRUE" />

</form>

</body>
</html>
<?php  
}

}


?>

Thank you,
genieuk

When you get a white page it usually means there was a fatal error and you don't have error reporting turned on. At the top of your script put error_reporting(E_ALL); (Take this out once you put the site live, you don't want errors showing on your page when you're not developing.

When you get a white page it usually means there was a fatal error and you don't have error reporting turned on. At the top of your script put error_reporting(E_ALL); (Take this out once you put the site live, you don't want errors showing on your page when you're not developing.

Hi i done what you said and no different, so i added echo before it and all i got was 6135

don't know what that suppose to mean or if it means anything. Also i do have error reporting turned on.

Any suggestions please anyone?

Thank you,
genieuk

heh, E_ALL is a PHP constant that tells error_reporting to display all errors, it doesn't mean anything to you. If that doesn't work then if you have command line access type php -l filename obviously replacing filename with the file that's giving you trouble.

hi,

I am a newbie php programmer i dont understand what you mean.

You could please describe in full detail for me please?

May i also ask can you see anything wrong with it looking at the form?

Thank you
genieuk

try this

}} else {
<?php  
}
?>

from what i see is that you only closed the
if (isset($_POST)) {
and not
if( $err == 0 ) {

Oh and yes you do want to make sure that errors are not turned off. check with your server peoples to make sure that errors are on

hi,

I am a newbie php programmer i dont understand what you mean.

You could please describe in full detail for me please?

May i also ask can you see anything wrong with it looking at the form?

Thank you
genieuk

Frankly there's a lot wrong but let's solve one issue at a time. The steps I'm walking you through are to debug. If error_reporting didn't give you an error then make sure to check your scripts for a "die" or "exit" function.

try this

}} else {
<?php  
}
?>

from what i see is that you only closed the
if (isset($_POST)) {
and not
if( $err == 0 ) {

Oh and yes you do want to make sure that errors are not turned off. check with your server peoples to make sure that errors are on

THANK YOU!!! It worked, i removed one from the end of the form and put one where you said, thank god for that.

Frankly there's a lot wrong but let's solve one issue at a time. The steps I'm walking you through are to debug. If error_reporting didn't give you an error then make sure to check your scripts for a "die" or "exit" function.

Hi, thanks all sorted now, also when you say there's alot wrong are you saying my form is terribly scripted? I am new and learning so if so please be trutful and let me know.

Thanks to both of you,
genieuk

Can i also ask please....

How would i be able to have it show the for example password incorrect text if not entered etc underneath the password ?

another thing could you tell me how i make it so i put the mysql injection thingy on the database part so my DB cannot be hacked?, for example i dont want someone entering code into form boxes so my db could be deleted etc, i use a variety of security methods already but still think i need the mysq injection thing, sorry cannot remember the actual syntax.

I want to make it secure as possible.

Thanks
genieuk

THANK YOU!!! It worked, i removed one from the end of the form and put one where you said, thank god for that.

Hi, thanks all sorted now, also when you say there's alot wrong are you saying my form is terribly scripted? I am new and learning so if so please be trutful and let me know.

Thanks to both of you,
genieuk

from an html stand point your are failing. i would suggest that you get into css. it is more powerful than <font> tags

from an html stand point your are failing. i would suggest that you get into css. it is more powerful than <font> tags

Hi, I am removing them, they are only there until i decide on a design.

I use dreamweaver as it seems to be very helpful for this sort of thing.

Althou i am no expert i have learnt how to use css in dreamweaver.

I am trying to find a nice css template for dreamweaver to help me speed things up, once i got a template i can start making big impacts.

I have looked everywhere but cant seem to find any nice decent ones.

Regards,
Mathew

Also if you or someone could answer my question 2 posts above this one that would be much appreciated.

on the first question you already do that.

if ( empty ($_POST['pass2'] ) ) { // Check if confirm password field is empty. If it is tell them
	echo "<font color=\"#FF3F00\" face=\"Verdana, Geneva, sans-serif\"><p>Please Confirm Your Password</p></font>";
    $err++;
}

on the second question i would make a new post. but that is just me. But you are still not done here though. you still need to fix the non displaying errors. and i am not thr person to ask about that

on the first question you already do that.

if ( empty ($_POST['pass2'] ) ) { // Check if confirm password field is empty. If it is tell them
	echo "<font color=\"#FF3F00\" face=\"Verdana, Geneva, sans-serif\"><p>Please Confirm Your Password</p></font>";
    $err++;
}

on the second question i would make a new post. but that is just me. But you are still not done here though. you still need to fix the non displaying errors. and i am not thr person to ask about that

Hi what i meant was it does display i know that but i rahter it display it under the form field boxes, once user submits data if it not validated it removes the form and displays the errors.

Ok thanks will create a new post,

this one is solved.

once again thanks.

This question has already been answered. Start a new discussion instead.