Member registration [Email won't connect to database]

PSTCAT
PSTCAT used Ask the Experts™
on
Basically, I have a registration form with 3 text fields. Username, Password and Email.

The username and password appear in my database when signing up but the email is refusing to.
I have two files, reg.php and regcheck.php.

Here is my code:

reg.php
<?php
require_once 'database.php';
?>
<body>
<form method="post" action="regcheck.php" name="register">
  <br>
<label for="username">Username: </label>
<br>
<input id="username" class="input_field" type="text" onmouseout="if(this.value==''){this.value='Username...';}" onclick="javascript:void(0);if(this.value=='Username...'){this.value='';}" maxlength="150" value="Username..." size="35" name="user">
<br>
<br>
<label for="password">Password: </label>
<br>
<input id="password" class="input_field" type="password" onmouseout="if(this.value==''){this.value='Password...';}" onclick="javascript:void(0);if(this.value=='Password...'){this.value='';}" maxlength="100" value="Password..." size="35" name="pass">
<br>
<br>
<label for="email">Email: </label>
<br>
<input id="email" class="input_field" type="email" onmouseout="if(this.value==''){this.value='Email...';}" onclick="javascript:void(0);if(this.value=='Email...'){this.value='';}" maxlength="100" value="Email..." size="35" name="email">
<br />
<br />
<input id="search_btn" type="submit" value="Continue" >
<b>I agree to the Terms &amp; Conditions.</b>
<br>
</form>

Open in new window


regcheck.php
<?php
if(
    isset( $_POST['user'] ) &&
    isset( $_POST['pass'] )
	isset( $_POST['email'] ))
{
    if( strlen( $_POST['user'] ) < 4 )
    {
        echo "Username Must Be More Than 4 Characters.";
    }
    elseif( strlen( $_POST['pass'] ) < 4 )
    {
        echo "Passwrod Must Be More Than 4 Characters.";
    }
	 elseif( strlen( $_POST['email'] ) < 4 )
    {
        echo "Email must be valid.";
    }
    elseif( $_POST['pass'] == $_POST['user'] )
    {
        echo"Username And Password Can Not Be The Same.";
    }
    else
    {
        include( 'database.php' );

        $username = mysql_real_escape_string( $_POST['user'] );
        $password = md5( $_POST['pass'] );
		$email = ( $_POST['email'] );

        $sqlCheckForDuplicate = "SELECT username FROM user WHERE username = '". $username ."'";

        
        if( mysql_num_rows( mysql_query( $sqlCheckForDuplicate ) ) == 0 )
        {
            $sqlRegUser =     "INSERT INTO
                        user( username, password, email )
                    VALUES(
                        '". $username ."',
                        '". $password ."',
						'". $email ."',
						 )";

            if( !mysql_query( $sqlRegUser ) )
            {
                echo "You Could Not Register Because Of An Unexpected Error.";
            }
            else
            {
                echo "You Are Registered And Can Now Login";
                $formUsername = $username;
                
                header ('location: Login.php');
            }
        }
        else
        {
            echo "The Username You Have Chosen Is Already Being Used By Another User. Please Try Another One.";
            $formUsername = $username;
        }
    }
}
else
{
    echo "You Could Not Be Registered Because Of Missing Data.";
}
?>

Open in new window


Any help would be appreciated, I can't seem to find any errors. Maybe I'm missing something...
Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Use
$email = $_POST['email'];
in your second file

Author

Commented:
Perfect.
Thanks!
No problem, thank you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial