"Please fill in all fields"

Discussion in 'Web Design and Development' started by JLEW700, Jul 25, 2009.

  1. JLEW700 macrumors 6502

    Joined:
    Aug 12, 2008
    #1
    Im working on a registration page, and when all the fields are filled in and I click submit, it says "Please fill in all fields." does anybody know why it is giving me this message even though all my fields are filled in?



    Heres my code:
    Code:
    <?php
    echo "<h1>Register</h1>";
    
    $submit = $_POST['submit'];
    
    $firstname = strip_tags($_POST['firstname']);
    $lastname = strip_tags($_POST['lastname']);
    $address = strip_tags($_POST['address']);
    $city = strip_tags($_POST['city']);
    $country = strip_tags($_POST['country']);
    $state = strip_tags($_POST['state/provence']);
    $zipcode = strip_tags($_POST['zipcode']);
    $username = strtolower(strip_tags($_POST['username']));
    $password = strip_tags($_POST['password']);
    $repeatpassword = strip_tags($_POST['repeatpassword']);
    $date = date("y-m-d");
    
    
    if ($submit)
    {
    
    	$connect = mysql_connect("localhost","root","");
    	mysql_select_db("phplogin");
    
    	$namecheck = mysql_query("SELECT username FROM users WHERE username='$username'");
    	$count = mysql_num_rows($namecheck);
    
    	if ($count!=0)
    	{
    
    	die("Username already taken.");
    
    	}
    
    
    if ($firstname&&$lastname&&$address&&$city&&$country&&$state&&$zipcode&&$username&&$password&&$repeatpassword)
    {
    	if ($password==$repeatpassword)
    	{
    	if (strlen($username)>25)
    	{
    	echo "Length of username is too long.";
    
    	}
    	else
    	{
    	if ( strlen($password) > 25 || strlen($password) < 6 )
        { 
    	echo "Password must be between 6 and 25 characters";
    	}
    	else
    	{
    		$password = md5($password);
    	$repeatpassword = md5($repeatpassword);
    
    	$queryreg = mysql_query("
    
    	INSERT INTO users VALUES ('','$firstname','$lastname','$address','$city','$country','$state','$zipcode','$username','$password','$date')
    
    ");
    
    die("You have been registered <a href='index.php'>Return to login page</a>");
    
    
    		}
    
    	}
    
    }
    	else
    		echo "Your passwords do not match";
    
    	
    }
    else
    	echo "Please fill in <b>all</b> fields.";
    
    }
    
    ?>
    <p>
    
    
    
    
    
    <html>
     <head>
    	<title>LinkedMail</title>
    	<link rel="stylesheet" type="text/css" href="Unrestricted.css">
    	
    	
    
     </head>
    
    <body>
    
    <table name="top" bgcolor=3399FF height=5% width=100%>
    	
    		<td align=right <font size=+4>LinkedMail</font></td>
    
    		<td align=right bgcolor=3399FF><form name="searchbox" action="http://www.google.com/cse?" method=get align=top>
    	<input type="textbox" name="q">
    	<input type="submit" value="Search"></form></td>
    </table>
    
    <form action='register.php' method='POST'>
    	<table name="Registration" bgcolor=white>
    <tr>
    	<td>
    	First Name:
    	</td>
    	<td>
    	<input type='text name='firstname' value='<?php echo $firstname; ?>'>
    	</td>
    	<td>
    	Last Name
    	</td>
    	<td>
    	<input type='text name='lastname' value='<?php echo $lastname; ?>'>
    	</td>
    </tr>
    <tr>
    	<td>
    	Address:
    	</td>
    	<td>
    	<input type='text' name='address' value='<?php echo $address; ?>'>
    	</td>
    
    	<td>
    	City:
    	</td>
    	<td>
    	<input type='text' name='city' value='<?php echo $city; ?>'>
    	</td>
    </tr>
    <tr>	
    	<td>
    	Country:
    	</td>
    	<td>
    	<input type='text' name='country' value='<?php echo $country; ?>'>
    	</td>
    
    	<td>
    	State/Provence:
    	</td>
    	<td>
    	<input type='text' name='state' value='<?php echo $state; ?>'>
    	</td>
    	
    </tr>
    <tr>
    	<td>
    	Zip Code:
    	</td>
    	<td><input type='text' name='zipcode' value='<?php echo $zipcode; ?>'>
    	</td>
    </tr>
    
    </table>
    <br>
    <br>
    
    <table name="ID" bgcolor=white>
    
    <tr>
    	<td>
    	Preferred User Name:
    	</td>
    	<td><input type='text' name='username' value='<?php echo 	$username; ?>'>
    	</td>
    </tr>
    <tr>
    	<td>Create a Password</td>
    	<td>
    	<input type='password' name='password'>
    	</td>
    </tr>
    <tr>
    
    	<td>Retype Password</td>
    
    	<td><input type='password' name='repeatpassword'></td>
    </tr>
    	</table> 
    	<p>
    	<input type='submit' name='submit' value='Register'>
    
    </form>
    
    
    <table name="bottom" bgcolor=3399FF height=5% width=100%>
    	
    <tr>	
    
    	<td align=center><font color="white" align="right"><a href="ContactUs.html">Contact Us</a></td>
    
    	<td align=center><font color=white size=5>|</td>
    
    	<td align=center><font color="white" align="right"><a href="About.html">About</a></td>
    
    	<td align=center><font color=white size=5>|</td>
    
    	<td align=center><font color="white" align="right"><a href="Privacy.html">Privacy</a></td>
    
    	<td align=center><font color=white size=5>|</td>
    
    	<td align=center><font color="white" align="right"><a href="Terms.html">Terms</a></td>
    
    </tr>	
    
    
    </table>
    </body>
    </html>
    
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    Likely this line,
    PHP:
    $state strip_tags($_POST['state/provence']);
    In the form the name of the element is "state" not "state/provence" so that line will become,
    PHP:
    $state strip_tags($_POST['state']);
     
  3. JLEW700 thread starter macrumors 6502

    Joined:
    Aug 12, 2008
    #3
    ^ Ok, I changed that and I still get the same thing. Also as a side note, when I fill all the fields in the form in, they all recognize what I have prevously typed and want to auto fill the information in, except for "first name" and "last name", and then once everything is filled in and I hit submit, I get the message "Please fill in all fields" and it clears "first name" and "last name", along with "password" and "retype password" but leaves all the other fields filled in. So do you think that it has something to do with "first name" and "last name".

    Heres the updated code:
    Code:
    <?php
    echo "<h1>Register</h1>";
    
    $submit = $_POST['submit'];
    
    $firstname = strip_tags($_POST['firstname']);
    $lastname = strip_tags($_POST['lastname']);
    $address = strip_tags($_POST['address']);
    $city = strip_tags($_POST['city']);
    $country = strip_tags($_POST['country']);
    $state = strip_tags($_POST['state']);
    $zipcode = strip_tags($_POST['zipcode']);
    $username = strtolower(strip_tags($_POST['username']));
    $password = strip_tags($_POST['password']);
    $repeatpassword = strip_tags($_POST['repeatpassword']);
    $date = date("y-m-d");
    
    
    if ($submit)
    {
    
    	$connect = mysql_connect("localhost","root","");
    	mysql_select_db("phplogin");
    
    	$namecheck = mysql_query("SELECT username FROM users WHERE username='$username'");
    	$count = mysql_num_rows($namecheck);
    
    	if ($count!=0)
    	{
    
    	die("Username already taken.");
    
    	}
    
    
    if ($firstname&&$lastname&&$address&&$city&&$country&&$state&&$zipcode&&$username&&$password&&$repeatpassword)
    {
    	if ($password==$repeatpassword)
    	{
    	if (strlen($username)>25)
    	{
    	echo "Length of username is too long.";
    
    	}
    	else
    	{
    	if ( strlen($password) > 25 || strlen($password) < 6 )
        { 
    	echo "Password must be between 6 and 25 characters";
    	}
    	else
    	{
    		$password = md5($password);
    	$repeatpassword = md5($repeatpassword);
    
    	$queryreg = mysql_query("
    
    	INSERT INTO users VALUES ('','$firstname','$lastname','$address','$city','$country','$state','$zipcode','$username','$password','$date')
    
    ");
    
    die("You have been registered <a href='index.php'>Return to login page</a>");
    
    
    		}
    
    	}
    
    }
    	else
    		echo "Your passwords do not match";
    
    	
    }
    else
    	echo "Please fill in <b>all</b> fields.";
    
    }
    
    ?>
    <p>
    
    
    
    
    
    <html>
     <head>
    	<title>LinkedMail</title>
    	<link rel="stylesheet" type="text/css" href="Unrestricted.css">
    	
    	
    
     </head>
    
    <body>
    
    <table name="top" bgcolor=3399FF height=5% width=100%>
    	
    		<td align=right <font size=+4>LinkedMail</font></td>
    
    		<td align=right bgcolor=3399FF><form name="searchbox" action="http://www.google.com/cse?" method=get align=top>
    	<input type="textbox" name="q">
    	<input type="submit" value="Search"></form></td>
    </table>
    
    <form action='register.php' method='POST'>
    	<table name="Registration" bgcolor=white>
    <tr>
    	<td>
    	First Name:
    	</td>
    	<td>
    	<input type='text name='firstname' value='<?php echo $firstname; ?>'>
    	</td>
    	<td>
    	Last Name
    	</td>
    	<td>
    	<input type='text name='lastname' value='<?php echo $lastname; ?>'>
    	</td>
    </tr>
    <tr>
    	<td>
    	Address:
    	</td>
    	<td>
    	<input type='text' name='address' value='<?php echo $address; ?>'>
    	</td>
    
    	<td>
    	City:
    	</td>
    	<td>
    	<input type='text' name='city' value='<?php echo $city; ?>'>
    	</td>
    </tr>
    <tr>	
    	<td>
    	Country:
    	</td>
    	<td>
    	<input type='text' name='country' value='<?php echo $country; ?>'>
    	</td>
    
    	<td>
    	State/Provence:
    	</td>
    	<td>
    	<input type='text' name='state' value='<?php echo $state; ?>'>
    	</td>
    	
    </tr>
    <tr>
    	<td>
    	Zip Code:
    	</td>
    	<td><input type='text' name='zipcode' value='<?php echo $zipcode; ?>'>
    	</td>
    </tr>
    
    </table>
    <br>
    <br>
    
    <table name="ID" bgcolor=white>
    
    <tr>
    	<td>
    	Preferred User Name:
    	</td>
    	<td><input type='text' name='username' value='<?php echo 	$username; ?>'>
    	</td>
    </tr>
    <tr>
    	<td>Create a Password</td>
    	<td>
    	<input type='password' name='password'>
    	</td>
    </tr>
    <tr>
    
    	<td>Retype Password</td>
    
    	<td><input type='password' name='repeatpassword'></td>
    </tr>
    	</table> 
    	<p>
    	<input type='submit' name='submit' value='Register'>
    
    </form>
    
    
    <table name="bottom" bgcolor=3399FF height=5% width=100%>
    	
    <tr>	
    
    	<td align=center><font color="white" align="right"><a href="ContactUs.html">Contact Us</a></td>
    
    	<td align=center><font color=white size=5>|</td>
    
    	<td align=center><font color="white" align="right"><a href="About.html">About</a></td>
    
    	<td align=center><font color=white size=5>|</td>
    
    	<td align=center><font color="white" align="right"><a href="Privacy.html">Privacy</a></td>
    
    	<td align=center><font color=white size=5>|</td>
    
    	<td align=center><font color="white" align="right"><a href="Terms.html">Terms</a></td>
    
    </tr>	
    
    
    </table>
    </body>
    </html>
    
     

Share This Page