Form submission and stopping on errors


#1

I was wondering if somebody from here could help, after reading numerous tutorials i have got as far as i can, i’m making a form that lets a visitor to my website information which is added to a database. The thing is, i can’t get the script to stop and inform the user there is missing information, and until it’s completed the form wont submit to the database.

I’m using a mysql database and have the submission part of the code working… I’ve attached my script so you can take a look.

Thanks


<?php 

if (isset($_POST['submitted'])) {

	// Clean up the bike details
	$manufacturer = mysql_escape_string(trim($_POST['manufacturer']));
	$model = mysql_escape_string(trim($_POST['model']));
	$capacity = mysql_escape_string(trim($_POST['capacity']));
	$year = mysql_escape_string(trim($_POST['year']));
  
    // Clean up the parts 
    $part_one = mysql_escape_string(trim($_POST['part_one']));
    $part_two = mysql_escape_string(trim($_POST['part_two']));
    $part_three = mysql_escape_string(trim($_POST['part_three']));
    $part_four = mysql_escape_string(trim($_POST['part_four'])); 
    $part_five = mysql_escape_string(trim($_POST['part_five']));
	
	// Clean up the personal details, some of these don't need cleaning up, i.e the contact prefrence
	$full_name = mysql_escape_string(trim($_POST['full_name']));
	$telephone = mysql_escape_string(trim($_POST['telephone']));
	$alt_telephone = mysql_escape_string(trim($_POST['alt_telephone']));
	$email = mysql_escape_string(trim($_POST['email']));
    $area = mysql_escape_string(trim($_POST['area']));
    
    // Fields that do not need cleaning up
    $status = $_POST['status'];
    $sent = $_POST['sent'];
    $contact_pref = $_POST['contact_pref'];
      
    
    // Check for required fields
    $errors = array();
    
    if(empty($manufacturer) || $manufacturer == "") {
          $errors[] = 'Please select a manafacturer';
    }      
    
    if(empty($model) || $model == "") {
          $errors[] = 'Please enter a model';
    }

	if(empty($year) || $year == "") {
          $errors[] = 'Please select a year';
    }
    
    if(empty($part_one) || $part_one == "") {
          $errors[] = 'Please enter at least one part';
    }
     
    if(empty($full_name) || $full_name == "") {
          $errors[] = 'Please enter your name';
    } 
    
    if(empty($email) || $email == "") {
          $errors[] = 'Please enter your email address';
    } 
     
    // Do we have any errors? 
    if(count($errors == 0)) {
	
	// If we don't, run the insert query
    $dbid = mysql_connect ('localhost', 'username', 'password');
	          mysql_select_db('database,$dbid) 
	          or die ("Cannot find database");
	
	  $query = "INSERT INTO `request_data` (`req_id`, `manufacturer`, `model`, `capacity`, `year`, `part_one`, `part_two`, `part_three`, `part_four`, `part_five`, `full_name`, `telephone`, `alt_telephone`, `email`, `contact_pref`, `area`, `status`, `sent`) VALUES ('', '$manufacturer', '$model', '$capacity', '$year', '$part_one', '$part_two', '$part_three', '$part_four', '$part_five', '$full_name', '$telephone', '$alt_telephone', '$email', '$contact_pref', '$area', '$status', '$sent')";
	  $result = mysql_query($query,$dbid) 
	   or die("INSERT error:".mysql_error());
	 
	 
	// If all is cool, this will redirect to a thank you page.
	  echo 'Form submitted';
	  exit;
	}
	
	else {
   		return false;
	}
	
	

    
   

}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 

<html>
<head>
<title>Request Submission Page</title>
</head>
<body>

<?php 
if (isset($_POST['submitted']) && count($errors) > 0) {

 echo '<strong>The following fields need to be corrected:</strong><br />';
 foreach($errors as $err => $val) {
  echo $val . '<br />';
 }
}
?>


<form enctype="multipart/form-data" method="post" action="">

<!--Make & Model Begin-->
	Manufacturer (Required):  
	<select name="manufacturer">
        <option value="" SELECTED>
        <option value="Aprilia">Aprilia
        <option value="Benelli">Benelli
		<option value="Beta">Beta
		<option value="Bimota">Bimota
		<option value="BMW">BMW
		<option value="BSA">BSA	
		<option value="Buell">Buell
		<option value="BMW">BMW
		<option value="Cagiva"> Cagiva
		<option value="CCM">CCM
		<option value="Derbi">Derbi
		<option value="Ducati">Ducati
		<option value="Enfield">Enfield
		<option value="Gillera">Gilera
		<option value="Harley-Davidson">Harley-Davidson
		<option value="Honda">Honda
		<option value="Husqvarna">Husqvarna
		<option value="Hyosung">Hyosung
		<option value="Italijet">Italijet
		<option value="Kawasaki">Kawasaki
		<option value="Kymco">Kymco
		<option value="Laverda">Laverda
		<option value="Moto Guzzi">Moto Guzzi
		<option value="MV Agusta">MV Agusta
		<option value="MZ">MZ
		<option value="Norton">Norton
		<option value="NRG">NRG
		<option value="Peugeot">Peugeot
		<option value="Sachs">Sachs
		<option value="Suzuki">Suzuki
		<option value="Triumph">Triumph
		<option value="Vespa">Vespa
		<option value="Yamaha">Yamaha		
	</select><br>
	Model (Required):<input type="text" name="model"><br>
	Engine Size (cc):<input type="text" name="capacity"><br>
	Year (Required): 
	<?php echo '<select name="year">';
	echo"<option value="/"></option>";
	for($x = 1950; $x <= 2007; $x++)
	{
	echo "<OPTION VALUE=$x>$x</OPTION>";
	}
	echo "</SELECT>";
	?>
<!-- Make & Model End -->
	<br><br>

<!-- Parts Begin-->	
	Part One (Required):<input type="text" name="part_one"><br>
	Part Two:<input type="text" name="part_two"><br>
	Part Three:<input type="text" name="part_three"><br>
	Part Four:<input type="text" name="part_four"><br>
	Part Five:<input type="text" name="part_five"><br>
<!--Parts End-->
	<br><br>

<!--Details Begin-->
	Full Name (Required):<input type="text" name="full_name"><br>
	Telephone:<input type="text" name="telephone"><br>
	Alternative Telephone:<input type="text" name="alt_telephone"><br>
	E-mail Address:<input type="text" name="email"><br>
	Contact Me By:
	<input type="radio" name="contact_pref" value="Email">Email
	<input type="radio" name="contact_pref" value="Telephone">Telephone<br> 
	Area:
	<select name="area">
        <option value="" SELECTED>
        <option value="Northern Ireland">Northern Ireland
        <option value="Southern Ireland">Southern Ireland
		<option value="Midlands">Midlands
		<option value="North East">North East
		<option value="North West">North West
		<option value="South East">South East
		<option value="South West">South West
		<option value="Scotland">Scotland
		<option value="Wales">Wales
		<option value="Outside UK">Outside UK
     </select><br>
     Comments:<textarea rows="5" cols="30" value="comments"></textarea>
<!-- Details End -->	
<!-- Hidden Fields Begin -->
	<input type="hidden" name="status" value="unchecked" />
	<input type="hidden" name="sent" value="no" />
	
	<!-- Hidden Fields End -->



<br><br>
<?php 
if (isset($_POST['submitted']) && count($errors) > 0) {

 echo '<strong>The following fields need to be corrected:</strong><br />';
 foreach($errors as $err => $val) {
  echo $val . '<br />';
 }
}
?>
<br><br>
	<input type="submit" name="submitted" value="Submit" ></td></tr>




</form>
</body>
</html>

#2

if(count($errors == 0))
should be:
if(count($errors) == 0)

this makes ur script being emply on errors

   else {
         return false;
   }

just remove it

one more improvement:
if you add the posted data to the html it will keep the values after an error.
e.g.:


#3

That was an error but removing it doesn’t do anything, the form is stull submitting despite the required fields being empty…


#4

i put one more thing i found inside my previose post.
don’t know if u read that as well.

are there any error-messages now?


#5

I’ve got the error code working so it displays the error messages when the required information is missing. One problem i’m having is getting the $year_error coming up when a year isn’t entered. If i change the variable to $part_error it displays that error message correctly but as soon as i change it to year it isn’t coming up. Any ideas? One other thing, the redirect isn’t redirecting when the form is submitted, why is this?

The code is below.

Thanks


<?php 

if (isset($_POST['submitted'])) {

	$valid = 1;
	
	// Pike details
	$manufacturer = mysql_escape_string(trim($_POST['manufacturer']));
		if ( empty($manufacturer) ) {
			$valid = 0;
			$manufacturer_error = 'Please select a manufacturer.';
		}
	
	$model = mysql_escape_string(trim($_POST['model']));
		if ( empty($model) ) {
			$valid = 0;
			$model_error = 'Please enter the model of bike..';
		}
	
	$capacity = mysql_escape_string(trim($_POST['capacity']));
	
	$year = mysql_escape_string(trim($_POST['year']));
  		if ( empty($year) ) {
			$valid = 0;
			$year_error = 'Please select a year.';
		}
  
  
  
    // Parts 
    $part_one = mysql_escape_string(trim($_POST['part_one']));
    	if ( empty($part_one) ) {
			$valid = 0;
			$part_error = 'Please enter a part.';
		}
    
    $part_two = mysql_escape_string(trim($_POST['part_two']));
    $part_three = mysql_escape_string(trim($_POST['part_three']));
    $part_four = mysql_escape_string(trim($_POST['part_four'])); 
    $part_five = mysql_escape_string(trim($_POST['part_five']));
	
	// Personal details, some of these don't need cleaning up, i.e the contact prefrence
	$full_name = mysql_escape_string(trim($_POST['full_name']));
		if ( empty($full_name) ) {
			$valid = 0;
			$name_error = 'Please enter a name.';
		}
		
	$telephone = mysql_escape_string(trim($_POST['telephone']));
	$alt_telephone = mysql_escape_string(trim($_POST['alt_telephone']));
	$email = mysql_escape_string(trim($_POST['email']));
    	if ( empty($email) ) {
			$valid = 0;
			$email_error = 'Please enter an email address.';
		}
    
    $area = mysql_escape_string(trim($_POST['area']));
    
    // Fields that do not need cleaning up
    $status = $_POST['status'];
    $sent = $_POST['sent'];
    $contact_pref = $_POST['contact_pref'];
      
    // Do we have errors?  
    if ( $valid == 1 ) {
    
	
	// If we don't, run the insert query
    $dbid = mysql_connect ('localhost', 'username', 'password');
	          mysql_select_db('database',$dbid) 
	          or die ("Cannot find database");
	
	  $query = "INSERT INTO `request_data` (`req_id`, `manufacturer`, `model`, `capacity`, `year`, `part_one`, `part_two`, `part_three`, `part_four`, `part_five`, `full_name`, `telephone`, `alt_telephone`, `email`, `contact_pref`, `area`, `status`, `sent`) VALUES ('', '$manufacturer', '$model', '$capacity', '$year', '$part_one', '$part_two', '$part_three', '$part_four', '$part_five', '$full_name', '$telephone', '$alt_telephone', '$email', '$contact_pref', '$area', '$status', '$sent')";
	  $result = mysql_query($query,$dbid) 
	   or die("INSERT error:".mysql_error());
	 
	 
	// If all is cool, this will redirect to a thank you page.
	  header ("Location: http://www.google.com");
	  exit;
	  
	  }
	
	}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 

<html>
<head>
<title>Request Submission Page</title>
</head>
<body>

<form enctype="multipart/form-data" method="post" action="">

<!--Make & Model Begin-->
	Manufacturer (Required):  
	<select name="manufacturer">
        <option value="" SELECTED>
        <option value="Aprilia">Aprilia
        <option value="Benelli">Benelli
		<option value="Beta">Beta
		<option value="Bimota">Bimota
		<option value="BMW">BMW
		<option value="BSA">BSA	
		<option value="Buell">Buell
		<option value="BMW">BMW
		<option value="Cagiva"> Cagiva
		<option value="CCM">CCM
		<option value="Derbi">Derbi
		<option value="Ducati">Ducati
		<option value="Enfield">Enfield
		<option value="Gillera">Gilera
		<option value="Harley-Davidson">Harley-Davidson
		<option value="Honda">Honda
		<option value="Husqvarna">Husqvarna
		<option value="Hyosung">Hyosung
		<option value="Italijet">Italijet
		<option value="Kawasaki">Kawasaki
		<option value="Kymco">Kymco
		<option value="Laverda">Laverda
		<option value="Moto Guzzi">Moto Guzzi
		<option value="MV Agusta">MV Agusta
		<option value="MZ">MZ
		<option value="Norton">Norton
		<option value="NRG">NRG
		<option value="Peugeot">Peugeot
		<option value="Sachs">Sachs
		<option value="Suzuki">Suzuki
		<option value="Triumph">Triumph
		<option value="Vespa">Vespa
		<option value="Yamaha">Yamaha		
	</select>
	<?php echo $manufacturer_error; ?><br>
	
	Model (Required):<input type="text" name="model">
	<?php echo $model_error; ?><br>
	
	
	Engine Size (cc):<input type="text" name="capacity"><br>
	
	Year (Required): 
	<?php echo '<select name="year">';
	echo"<option value="/"></option>";
	for($x = 1950; $x <= 2007; $x++)
	{
	echo "<option value=$x>$x</option>";
	}
	echo "</select> ";
	echo $year_error;
	?>
<br>
	
	
<!-- Make & Model End -->
	<br><br>

<!-- Parts Begin-->	
	Part One (Required):<input type="text" name="part_one">
	<?php echo $part_error; ?><br>
		
	Part Two:<input type="text" name="part_two"><br>
	Part Three:<input type="text" name="part_three"><br>
	Part Four:<input type="text" name="part_four"><br>
	Part Five:<input type="text" name="part_five"><br>
<!--Parts End-->
	<br><br>

<!--Details Begin-->
	Full Name (Required):<input type="text" name="full_name">
	<?php echo $name_error; ?><br>
		
	Telephone:<input type="text" name="telephone"><br>
	Alternative Telephone:<input type="text" name="alt_telephone"><br>
	
	E-mail Address (Required):<input type="text" name="email">
	<?php echo $email_error; ?><br>
	
	Contact Me By:
	<input type="radio" name="contact_pref" value="Email">Email
	<input type="radio" name="contact_pref" value="Telephone">Telephone<br> 
	Area:
	<select name="area">
        <option value="" SELECTED>
        <option value="Northern Ireland">Northern Ireland
        <option value="Southern Ireland">Southern Ireland
		<option value="Midlands">Midlands
		<option value="North East">North East
		<option value="North West">North West
		<option value="South East">South East
		<option value="South West">South West
		<option value="Scotland">Scotland
		<option value="Wales">Wales
		<option value="Outside UK">Outside UK
     </select><br>
     Comments:<textarea rows="5" cols="30" value="comments"></textarea>
<!-- Details End -->	
<!-- Hidden Fields Begin -->
	<input type="hidden" name="status" value="unchecked" />
	<input type="hidden" name="sent" value="no" />
	
	<!-- Hidden Fields End -->




<br><br>
	<input type="submit" name="submitted" value="Submit" ></td></tr>




</form>
</body>
</html>

#6

Maybe this thread will help you out a bit: Errors …


#7

I’ve done this but am wondering how i get the selected radio button to remain checked as well as the pull down menus?

Thanks


#8
   <select name="area">
        <option value=""<?php if(!$_REQUEST['area']) echo ' selected="selected"' ?>/>
        <option value="Northern Ireland"<?php if($_REQUEST['area']=="Northern Ireland") echo ' selected="selected"' ?>/>Northern Ireland
        <option value="Southern Ireland"<?php if($_REQUEST['area']=="Southern Ireland") echo ' selected="selected"' ?>/>Southern Ireland

...

#9

Sorry to keep asking questions, could you tell me how i would get the form to remember the check boxes and the selected year.

The years are done on a loop but i can’t work out where to put the bit of code you showed me…

Also, i can’t get the $year_error message to display when a year isn’t selected. It’s obviously something to do with the way the loop is working…

Thanks


#10

no pronlem this is a php help forum.

for the loop you do the same. just 2 diffrences:

  • you are already inside php so instead of <?php you must end the echo an use a new line.
  • you don’t compare the request with a constant string but with the variable.

[php]
echo ‘’;
echo ‘’;
for($x = 1950; $x <= 2007; $x++)
{
echo “<option value=$x”;
if($_REQUEST[‘year’]==$x) echo ’ selected=“selected”’;
echo “>$x”;
}
echo " ";
echo $year_error;
[/php]

btw the ‘selected=“selected”’ is just the xhtml way of writing ‘SELCTED’. like ‘
’ vs. ‘
’. for the radio buttons u use ‘checked=“checked”’

i guess ur $year_error prob is causde by the forward slash (that made year always having a value):
[php]echo"";[/php]
use
[php]echo"";[/php]
or single quotes, as i always do
[php]echo ‘’;[/php]

hope it wokes now.


#11

This may help u, to simplify ur code:
http://phphelp.com/forums/viewtopic.php?p=29213


#12

That’s great, the script is working exactly like i want now, just one more question i promise… How would i keep what’s entered into the comments box? It’s a box.

I’ve had a look at the page you showed me and that is ultimately how i want my script to be, i’d like to set up arrays for the data, it would be a lot easier to add an option to the menu using that method.

Thanks for your help, you’ve been a great help.


#13

textareas work the same way.

<?php echo $_REQUEST['xxx'] ?>


#14

I did that it’s just that it wasn’t working, i double checked the code and realised i put the <?php echo $_REQUEST['xxx'] ?> inside of the opening tag. :D

The form is now functioning perfectly, i’m just wondering how i can add some bot protection, maybe a box that would require the user to enter some numbers randomly generated by the script.

Do you know of any guides that would explain the process to me?

Thanks,
Andrew


#15

i never needed bot protection for forms. but as long as your side is smaller than google, ebay … ;) a very simple bot protection would be enough.

i personalty like the one done by php.net.
http://www.php.net/manual/add-note.php? … /index.php
please don’t really submit, but use preview to test it.

you just need an $nums=array(1=>‘one’,‘two’,‘three’…) and add a simple calculation you may evern put the result as a number in a hidden field.

and on submission compare them by ‘if($nums[$_REQUEST[‘result’]]!=$_REQUEST[‘botprotectionfield’]) ERROR’

just try it out. and be creative.
Q


#16

I’ve had a little play during lunchtime at work and although i’ve got something working it’s a bit basic and to be honest i don’t think it will do the job…

I’ve got a random number that is generated and then put into a variable… Then the variable is printed next to an input box in the form, when the script is submitted, the number entered is checked against the number in the variable. The problem is that the variable needs to be printed next to the input box so the number can be seen in the html source.

Somebody suggested i store the random number in a session. How would i go about this?

Thanks


#17

What I’d do to make a submit form bot-proof, is something like this:

[random question] Which is a color?
[option] Car
[option] Blue
[option] Space

Any English-speaking human could easily answer this question correctly.
Unless we have a highly intelligent bot with a word categorization database on backend, you’ll be pretty safe. Said bots don’t usually target the smaller SOHO websites anyway.


#18

That is an excellent idea! :D

Once i have the form/script working fully, would you mind taking a look at it and giving me some advice on security?

Thanks


#19

Sure, I wouldn’t mind doing that. I’m not your average hacker but I’ll see what I can do :wink:


#20

Well, i’ve taken your advice about the colour thing and have just got it finished… The entire form can be seen below. It’s the first form i’ve done so i know it could do with being cleaned up a bit.

At some point i’d like to get some regex checking to make sure the data being entered is correct, i’d also like to pull the options for the pull down menus from a database rather than hard coding them in like i have done here…

Anyway here is the code, what would you do to it before putting it online for the public to use?

<?php 


    
   
   $colour = Red;
    
if (isset($_POST['submitted'])) {
	$valid = 1;
	
	// Bike details
	$manufacturer = mysql_escape_string(trim($_POST['manufacturer']));
		if ( empty($manufacturer) ) {
			$valid = 0;
			$manufacturer_error = 'Please select a manufacturer.';
		}
	
	$model = mysql_escape_string(trim($_POST['model']));
		if ( empty($model) ) {
			$valid = 0;
			$model_error = 'Please enter the model of bike..';
		}
	
	$capacity = mysql_escape_string(trim($_POST['capacity']));
	
	$year = mysql_escape_string(trim($_POST['year']));
  		if ( empty($year) ) {
			$valid = 0;
			$year_error = 'Please select a year.';
		  }
  
    // Parts 
    $part_one = mysql_escape_string(trim($_POST['part_one']));
    	if ( empty($part_one) ) {
			$valid = 0;
			$part_error = 'Please enter a part.';
		  }
    
    $part_two = mysql_escape_string(trim($_POST['part_two']));
    $part_three = mysql_escape_string(trim($_POST['part_three']));
    $part_four = mysql_escape_string(trim($_POST['part_four'])); 
    $part_five = mysql_escape_string(trim($_POST['part_five']));
	
	  // Personal details, some of these don't need cleaning up, i.e the contact prefrence
	  $full_name = mysql_escape_string(trim($_POST['full_name']));
		  if ( empty($full_name) ) {
			$valid = 0;
			$name_error = 'Please enter a name.';
		  }
		
	  $telephone = mysql_escape_string(trim($_POST['telephone']));
	  $alt_telephone = mysql_escape_string(trim($_POST['alt_telephone']));
	  $email = mysql_escape_string(trim($_POST['email']));
    	if ( empty($email) ) {
			$valid = 0;
			$email_error = 'Please enter an email address.';
		  }
    
    $area = mysql_escape_string(trim($_POST['area']));
    $comments = mysql_escape_string(trim($_POST['comments']));
    
     // Fields that do not need cleaning up
    $status = $_POST['status'];
    $sent = $_POST['sent'];
    $contact_pref = $_POST['contact_pref'];
    
    // Does the entered number match the generated number?
    
   
    if ($_REQUEST['spam_protect']!=$colour) {
      $valid = 0;
      $spam_error = 'Please try again.';
    }
     
      
    // Do we have errors?  
    if ( $valid == 1 ) {
    	
	  // If we don't, run the insert query
    $dbid = mysql_connect ('localhost', 'username', 'password');
	          mysql_select_db('database',$dbid) 
	          or die ("Cannot find database");
	
	  $query = "INSERT INTO `request_data` (`req_id`, `manufacturer`, `model`, `capacity`, `year`, `part_one`, `part_two`, `part_three`, `part_four`, `part_five`, `full_name`, `telephone`, `alt_telephone`, `email`, `contact_pref`, `area`, `status`, `sent`, `comments` ) VALUES ('', '$manufacturer', '$model', '$capacity', '$year', '$part_one', '$part_two', '$part_three', '$part_four', '$part_five', '$full_name', '$telephone', '$alt_telephone', '$email', '$contact_pref', '$area', '$status', '$sent', '$comments')";
	  $result = mysql_query($query,$dbid) 
	    or die("INSERT error:".mysql_error());
	 
	 
	  // If all is cool, this will redirect to a thank you page.
	    header ("Location: http://www.google.com");
	    exit;
	  
	  }
  }
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
<title>Request Submission Page</title>
</head>
<body>

<form enctype="multipart/form-data" method="post" action="">

<!--Make & Model Begin-->
	Manufacturer (Required):  
	<select name="manufacturer">
    <option value="" <?php if(!$_REQUEST['manufacturer']) echo ' selected="selected"' ?>/>
    <option value="Aprilia" <?php if($_REQUEST['manufacturer']=="Aprilia") echo ' selected="selected"' ?>/>Aprilia
    <option value="Benelli"  <?php if($_REQUEST['manufacturer']=="Benelli") echo ' selected="selected"' ?>/>Benelli
		<option value="Beta"  <?php if($_REQUEST['manufacturer']=="Beta") echo ' selected="selected"' ?>/>Beta
		<option value="Bimota"  <?php if($_REQUEST['manufacturer']=="Bimota") echo ' selected="selected"' ?>/>Bimota
		<option value="BMW"  <?php if($_REQUEST['manufacturer']=="BMW") echo ' selected="selected"' ?>/>BMW
		<option value="BSA"  <?php if($_REQUEST['manufacturer']=="BSA") echo ' selected="selected"' ?>/>BSA
		<option value="Buell"  <?php if($_REQUEST['manufacturer']=="Buell") echo ' selected="selected"' ?>/>Buell
		<option value="Cagiva"  <?php if($_REQUEST['manufacturer']=="Cagiva") echo ' selected="selected"' ?>/>Cagiva
		<option value="CCM"  <?php if($_REQUEST['manufacturer']=="CCM") echo ' selected="selected"' ?>/>CCM
		<option value="Derbi"  <?php if($_REQUEST['manufacturer']=="Derbi") echo ' selected="selected"' ?>/>Derbi
		<option value="Ducati"  <?php if($_REQUEST['manufacturer']=="Ducati") echo ' selected="selected"' ?>/>Duati
		<option value="Enfield"  <?php if($_REQUEST['manufacturer']=="Enfield") echo ' selected="selected"' ?>/>Enfield
		<option value="Gillera"  <?php if($_REQUEST['manufacturer']=="Gillera") echo ' selected="selected"' ?>/>Gillera
		<option value="Harley-Davidson"  <?php if($_REQUEST['manufacturer']=="Harley-Davidson") echo ' selected="selected"' ?>/>Harley-Davidson
		<option value="Honda"  <?php if($_REQUEST['manufacturer']=="Honda") echo ' selected="selected"' ?>/>Honda
		<option value="Husqvarna"  <?php if($_REQUEST['manufacturer']=="Husqvarna") echo ' selected="selected"' ?>/>Husqvarna
		<option value="Hyosung"   <?php if($_REQUEST['manufacturer']=="Hyosung") echo ' selected="selected"' ?>/>Hyosung
		<option value="Italijet"   <?php if($_REQUEST['manufacturer']=="Italijet") echo ' selected="selected"' ?>/>Italijet
		<option value="Kawasaki"   <?php if($_REQUEST['manufacturer']=="Kawasaki") echo ' selected="selected"' ?>/>Kawasaki
		<option value="Kymco"   <?php if($_REQUEST['manufacturer']=="Kymco") echo ' selected="selected"' ?>/>Kymco
		<option value="Laverda"   <?php if($_REQUEST['manufacturer']=="Husqvarna") echo ' selected="selected"' ?>/>Laverda
		<option value="Moto Guzzi"   <?php if($_REQUEST['manufacturer']=="Moto Guzzi") echo ' selected="selected"' ?>/>Moto Guzzi
		<option value="MV Agusta"   <?php if($_REQUEST['manufacturer']=="MV Agusta") echo ' selected="selected"' ?>/>MV Agusta
		<option value="MZ"   <?php if($_REQUEST['manufacturer']=="MZ") echo ' selected="selected"' ?>/>MZ
		<option value="Norton"   <?php if($_REQUEST['manufacturer']=="Norton") echo ' selected="selected"' ?>/>Norton
		<option value="NRG" <?php if($_REQUEST['manufacturer']=="NRG") echo ' selected="selected"' ?>/>NRG
		<option value="Peugeot"   <?php if($_REQUEST['manufacturer']=="Peugeot") echo ' selected="selected"' ?>/>Peugeot
		<option value="Sachs"   <?php if($_REQUEST['manufacturer']=="Sachs") echo ' selected="selected"' ?>/>Sachs
		<option value="Suzuki"   <?php if($_REQUEST['manufacturer']=="Suzuki") echo ' selected="selected"' ?>/>Suzuki
		<option value="Triumph"   <?php if($_REQUEST['manufacturer']=="Triumph") echo ' selected="selected"' ?>/>Triumph
		<option value="Vespa"   <?php if($_REQUEST['manufacturer']=="Vespa") echo ' selected="selected"' ?>/>Vespa
		<option value="Yamaha"   <?php if($_REQUEST['manufacturer']=="Yamaha") echo ' selected="selected"' ?>/>Yamaha
	</select>
	<?php echo $manufacturer_error; ?><br>
	
	Model (Required):<input type="text" name="model" value="<?php echo $model; ?>">
	<?php echo $model_error; ?><br>
		
	Engine Size (cc):<input type="text" name="capacity" value="<?php echo $capacity; ?>"><br>
	
	Year (Required):
	<?php
	echo '<select name="year">'; 
   echo '<option value=""></option>'; 
   for($x = 1950; $x <= 2007; $x++) 
     { 
       echo "<option value=$x"; 
       if($_REQUEST['year']==$x) echo ' selected="selected"'; 
       echo ">$x</option>"; 
     } 
   echo "</select> "; 
   echo $year_error;
	?>
<!-- Make & Model End -->
	<br><br>

<!-- Parts Begin-->	
	Part One (Required):<input type="text" name="part_one" value="<?php echo $part_one; ?>">
	<?php echo $part_error; ?><br>
		
	Part Two:<input type="text" name="part_two" value="<?php echo $part_two; ?>"><br>
	Part Three:<input type="text" name="part_three" value="<?php echo $part_three; ?>"><br>
	Part Four:<input type="text" name="part_four" value="<?php echo $part_four; ?>"><br>
	Part Five:<input type="text" name="part_five" value="<?php echo $part_five; ?>"><br>
<!--Parts End-->
	<br><br>

<!--Details Begin-->
	Full Name (Required):<input type="text" name="full_name" value="<?php echo $full_name; ?>">
	<?php echo $name_error; ?><br>
		
	Telephone:<input type="text" name="telephone" value="<?php echo $telephone; ?>"><br>
	Alternative Telephone:<input type="text" name="alt_telephone" value="<?php echo $alt_telephone; ?>"><br>
	
	E-mail Address (Required):<input type="text" name="email" value="<?php echo $email; ?>">
	<?php echo $email_error; ?><br>
	
	Contact Me By:
	<input type="radio" name="contact_pref" value="Email" <?php if($_REQUEST['contact_pref']=="Email") echo ' checked="checked"' ?>/>Email
	<input type="radio" name="contact_pref" value="Telephone" <?php if($_REQUEST['contact_pref']=="Telephone") echo ' checked="checked"' ?>/>Telephone<br>
	Area:
	<select name="area">
    <option value="" SELECTED>
    <option value="Northern Ireland"   <?php if($_REQUEST['area']=="Northern Ireland") echo ' selected="selected"' ?>/>Northern Ireland
    <option value="Southern Ireland"   <?php if($_REQUEST['area']=="Southern Ireland") echo ' selected="selected"' ?>/>Southern Ireland
		<option value="Midlands"   <?php if($_REQUEST['area']=="Midlands") echo ' selected="selected"' ?>/>Midlands
		<option value="North East"   <?php if($_REQUEST['area']=="North East") echo ' selected="selected"' ?>/>North East
		<option value="North West" <?php if($_REQUEST['area']=="North West") echo ' selected="selected"' ?>/>North West
		<option value="South East" <?php if($_REQUEST['area']=="South East") echo ' selected="selected"' ?>/>South East
		<option value="South West" <?php if($_REQUEST['area']=="South West") echo ' selected="selected"' ?>/>South West
		<option value="Scotland" <?php if($_REQUEST['area']=="Scotland") echo ' selected="selected"' ?>/>Scotland
		<option value="Wales" <?php if($_REQUEST['area']=="Wales") echo ' selected="selected"' ?>/>Wales
		<option value="Outside UK" <?php if($_REQUEST['area']=="Outside UK") echo ' selected="selected"' ?>/>Outside UK
  </select><br>

  Comments:<textarea name="comments" rows="5" cols="30"><?php echo $_REQUEST['comments'] ?></textarea><br>
<!-- Details End -->	

<!-- Hidden Fields Begin -->
	<input type="hidden" name="status" value="unchecked" />
	<input type="hidden" name="sent" value="no" />
	<!--<input type="hidden" name="sent" value="" />-->
<!-- Hidden Fields End -->
<br><br>

<!-- Spam Protection Begin -->
  SpamProtect: (Pick the colour) 
  <select name="spam_protect">
    <option value="" SELECTED>
    <option value="Dog"  <?php if($_REQUEST['spam_protect']=="Dog") echo ' selected="selected"' ?>/>Dog
    <option value="Cat"   <?php if($_REQUEST['spam_protect']=="Cat") echo ' selected="selected"' ?>/>Cat
		<option value="Red"   <?php if($_REQUEST['spam_protect']=="Red") echo ' selected="selected"' ?>/>Red
	</select>
  <?php echo $spam_error; ?><br>
<!-- Spam Protection End -->
<br><br>

<!-- Submit Begin -->
  <input type="submit" name="submitted" value="Submit" ></td></tr>
<!-- Submit End -->

</form>
</body>
</html>