Form Issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Chrisjc
    Contributor
    • Nov 2006
    • 375

    Form Issue

    I keep getting the error tags when I submit my form and it will not old / save an values or even pass it to my conversionTABLE .php file.... Any suggestions?

    Code:
    <html>
    
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Players / Foursome</title>
    </head>
    
    <body>
    
    <div align="center">
    	<table border="0" width="44%" height="646">
    		<tr>
    			<td valign="top">
    			<table border="0" width="100%" style="border-bottom-width: 0px">
    				<tr>
    					<td valign="top" style="border-bottom-style: none; border-bottom-width: medium">&nbsp;<b><font size="5">Players 
    					/ Foursome</font></b></td>
    				</tr>
    			</table>
    			<?php
    $errors = array();                        // array to hold error messages
    $ertags = array();                        // array to hold names of erroneous fields
    // ===========================================================================
    // When the form is submitted:
    // a. all fields: 'sanitize' by removing code tags
    // b. mandatory fields: check for validity and content (some)
    // ===========================================================================
    if (isset($_POST['_submit'])) {
      // ----------------------------------------------------
      // remove harmful code tags from all $_POST variables
      // ----------------------------------------------------
      foreach ($_POST as $key => $val) {
        $_POST[$key] = trim(strip_tags($val));
      }
      // ----------------------------------------------------
      // Verify existence and content of mandatory fields:
      //
      // Golfers Name   			Golfers Name
      // Guests Name     			Guests Name
      // Company       				Company
      // Home Address				Home Address
      // Phone	      				Phone
      // Fax      					Fax
      // Email      				E-mail           (valid e-mail address)
      // Room						Room
      // Smoking					Smoking
      // Shirt						Shirt
      // ----------------------------------------------------
      //
      // Golfers Name
      if (!isset($_POST['Golfers Name']) OR $_POST['Golfers Name'] == '') {
         $errors[] = "Golfers Name invalid";
         $ertags[] = 'Golfers Name';
      }
      // Guests Name
      if (!isset($_POST['Guests Name']) OR $_POST['Guests Name'] == '') {
         $errors[] = "Guests Name invalid";
         $ertags[] = 'Guests Name';
      }
      // Company
      if (!isset($_POST['Company']) OR $_POST['Company'] == '') {
         $errors[] = "Company invalid";
         $ertags[] = 'Company';
      }
      // Home Address
      if (!isset($_POST['Home Address']) OR $_POST['Home Address'] == '') {
         $errors[] = "Home Address invalid";
         $ertags[] = 'Home Address';
      }
        // Phone
      if (!isset($_POST['Phone']) OR $_POST['Phone'] == '') {
         $errors[] = "Phone invalid";
         $ertags[] = 'Phone';
      }
      // Fax
      if (!isset($_POST['Fax']) OR $_POST['Fax'] == '') {
         $errors[] = "Fax invalid";
         $ertags[] = 'Fax';
      }
      // Email (check also if valid e-mail address)
      if (!isset($_POST['Email']) OR !preg_match("/^[0-9a-z]+(([\.\-_])[0-9a-z]+)*@[0-9a-z]+(([\.\-])[0-9a-z-]+)*\.[a-z]{2,4}$/i", $_POST['Email'])) {
         $errors[] = "E-mail address invalid";
         $ertags[] = 'Email';
         }
      // Room
      if (!isset($_POST['Room']) OR $_POST['Room'] == '') {
         $errors[] = "Room invalid";
         $ertags[] = 'Room';
      }
      // Shirt
      if (!isset($_POST['Shirt']) OR $_POST['Shirt'] == '') {
         $errors[] = "Shirt invalid";
         $ertags[] = 'Shirt';
      }
      // -------------------------------------------------------
      // ERRORS FOUND: print out and re-display form
      // -------------------------------------------------------
      if ($errors) {
         echo '<div style="margin-left:250px;font-size:12px;font-family:Tahoma;color:red;">';
    	 echo '<u><b>The following errors were encountered (see highlighted fields):</b></u><ul><li>';
         echo implode('</li><li>',$errors);
         echo '</li></ul></div>';
      }
      else {
         // -------------------------------------------------------
         // NO ERRORS FOUND: continue and construct e-mail message
         // -------------------------------------------------------
         // echo '<pre>'; print_r($_POST); echo '<br>'; 
         include("convertPost.php");
         exit;
      }
      
    } // END if isset _submitted
    // ==================================================================================
    // (Re) Display the form
    // ==================================================================================
    ?>
    			<hr size="1" color="#000000">
    			<div align="center">
    				<form name="myForm" action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
    					<table border="0" cellspacing="10" cellpadding="3">
    						<tr>
    							<td style="border-style: solid; border-width: 1px" valign="top" width="344">
    							<table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
    								<tr>
    									<td valign="top" height="20" width="331" colspan="2">
    									<p align="center"><b><font size="4">Player 
    									One</font></b></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Golfers Name:</b><br>
    									<input type="text" name="P1GN" size="25" tabindex="1" value="<?php echo (isset($_POST['Golfers Name'])) ? $_POST['Golfers Name'] : ""; ?>"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Guests Name:</b><br>
    									<input type="text" name="P1GUN" size="25" tabindex="2" value="<?php echo (isset($_POST['Guests Name'])) ? $_POST['Guests Name'] : ""; ?>"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Company:</b><br>
    									<input type="text" name="P1C" size="30" tabindex="3" value="<?php echo (isset($_POST['Company'])) ? $_POST['Company'] : ""; ?>"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Home Address:</b><br>
    									<input type="text" name="P1HA" size="48" tabindex="4" value="<?php echo (isset($_POST['Home Address'])) ? $_POST['Home Address'] : ""; ?>"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="175"><b>
    									<font size="2">Phone:<br>
    									</font></b><font size="2">
    									<input type="text" name="P1P" size="20" tabindex="5" value="<?php echo (isset($_POST['Phone'])) ? $_POST['Phone'] : ""; ?>"></font></td>
    									<td valign="top" height="37" width="169">
    									<font size="2"><b>Fax:</b><br>
    									<input type="text" name="P1F" size="20" tabindex="6" value="<?php echo (isset($_POST['Fax'])) ? $_POST['Fax'] : ""; ?>"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Email:</b><br>
    									<input type="text" name="P1EM" size="38" tabindex="7" value="<?php echo (isset($_POST['Email'])) ? $_POST['Email'] : ""; ?>"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="35" width="331" colspan="2">
    									<b><font size="2">Room:<br>
    									<select size="1" name="P1R">
    									<option selected>Select Bed Size</option>
    									<option>King</option>
    									<option>Double</option>
    									<?php echo (isset($_POST['Room'])) ? $_POST['Room'] : ""; ?></select>&nbsp;&nbsp;&nbsp;&nbsp;
    									<select size="1" name="P1SM">
    									<option selected>Smoking or Non-Smoking
    									</option>
    									<option>Smoking</option>
    									<option>Non-Smoking</option>
    									<?php echo (isset($_POST['Smoking'])) ? $_POST['Smoking'] : ""; ?></select></font></b></td>
    								</tr>
    								<tr>
    									<td valign="top" height="50" width="331" colspan="2">
    									<b><font size="2"><br>
    									T-Shirt:<br>
    									<select size="1" name="P1TS">
    									<option selected>Select Your Size</option>
    									<option>XXL</option>
    									<option>XL</option>
    									<option>Large</option>
    									<option>Medium</option>
    									<option>Small</option>
    									<?php echo (isset($_POST['Shirt'])) ? $_POST['Shirt'] : ""; ?></select></font></b></td>
    								</tr>
    							</table>
    							</td>
    							<td style="border-style: solid; border-width: 1px" valign="top">
    							<table border="0" width="331" cellspacing="0" cellpadding="0" height="326">
    								<tr>
    									<td valign="top" height="19" width="331" colspan="2">
    									<p align="center"><b><font size="4">Player 
    									Two</font></b></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Golfers Name:</b><br>
    									<input type="text" name="T8" size="25"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Guests Name:</b><br>
    									<input type="text" name="T9" size="25"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Company:</b><br>
    									<input type="text" name="T10" size="30"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Home Address:</b><br>
    									<input type="text" name="T11" size="48"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="174"><b>
    									<font size="2">Phone:<br>
    									</font></b><font size="2">
    									<input type="text" name="T12" size="20"></font></td>
    									<td valign="top" height="37" width="170">
    									<font size="2"><b>Fax:</b><br>
    									<input type="text" name="T13" size="20"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Email:</b><br>
    									<input type="text" name="T14" size="38"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="35" width="331" colspan="2">
    									<b><font size="2">Room:<br>
    									<input type="checkbox" name="C10" value="ON">King&nbsp;
    									<input type="checkbox" name="C11" value="ON">Double&nbsp;
    									<input type="checkbox" name="C12" value="ON">Smoking&nbsp;
    									<input type="checkbox" name="C13" value="ON">Non-Smoking</font></b></td>
    								</tr>
    								<tr>
    									<td valign="top" height="50" width="331" colspan="2">
    									<b><font size="2"><br>
    									T-Shirt:<br>
    									<input type="checkbox" name="C14" value="ON">XXL&nbsp;
    									<input type="checkbox" name="C15" value="ON">XL&nbsp;
    									<input type="checkbox" name="C16" value="ON">Large&nbsp;
    									<input type="checkbox" name="C17" value="ON">Medium&nbsp;
    									<input type="checkbox" name="C18" value="ON">Small</font></b></td>
    								</tr>
    							</table>
    							</td>
    						</tr>
    						<tr>
    							<td style="border-style: solid; border-width: 1px" valign="top" width="344">
    							<table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
    								<tr>
    									<td valign="top" height="20" width="331" colspan="2">
    									<p align="center"><b><font size="4">Player 
    									Three</font></b></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Golfers Name:</b><br>
    									<input type="text" name="T15" size="25"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Guests Name:</b><br>
    									<input type="text" name="T16" size="25"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Company:</b><br>
    									<input type="text" name="T17" size="30"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Home Address:</b><br>
    									<input type="text" name="T18" size="48"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="173"><b>
    									<font size="2">Phone:<br>
    									</font></b><font size="2">
    									<input type="text" name="T19" size="20"></font></td>
    									<td valign="top" height="37" width="171">
    									<font size="2"><b>Fax:</b><br>
    									<input type="text" name="T20" size="20"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Email:</b><br>
    									<input type="text" name="T21" size="38"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="35" width="331" colspan="2">
    									<b><font size="2">Room:<br>
    									<input type="checkbox" name="C19" value="ON">King&nbsp;
    									<input type="checkbox" name="C20" value="ON">Double&nbsp;
    									<input type="checkbox" name="C21" value="ON">Smoking&nbsp;
    									<input type="checkbox" name="C22" value="ON">Non-Smoking</font></b></td>
    								</tr>
    								<tr>
    									<td valign="top" height="50" width="331" colspan="2">
    									<b><font size="2"><br>
    									T-Shirt:<br>
    									<input type="checkbox" name="C23" value="ON">XXL&nbsp;
    									<input type="checkbox" name="C24" value="ON">XL&nbsp;
    									<input type="checkbox" name="C25" value="ON">Large&nbsp;
    									<input type="checkbox" name="C26" value="ON">Medium&nbsp;
    									<input type="checkbox" name="C27" value="ON">Small</font></b></td>
    								</tr>
    							</table>
    							</td>
    							<td style="border-style: solid; border-width: 1px" valign="top">
    							<table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
    								<tr>
    									<td valign="top" height="20" width="331" colspan="2">
    									<p align="center"><b><font size="4">Player 
    									Four</font></b></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Golfers Name:</b><br>
    									<input type="text" name="T22" size="25"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Guests Name:</b><br>
    									<input type="text" name="T23" size="25"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Company:</b><br>
    									<input type="text" name="T24" size="30"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Home Address:</b><br>
    									<input type="text" name="T25" size="48"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="174"><b>
    									<font size="2">Phone:<br>
    									</font></b><font size="2">
    									<input type="text" name="T26" size="20"></font></td>
    									<td valign="top" height="37" width="170">
    									<font size="2"><b>Fax:</b><br>
    									<input type="text" name="T27" size="20"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="37" width="331" colspan="2">
    									<font size="2"><b>Email:</b><br>
    									<input type="text" name="T28" size="38"></font></td>
    								</tr>
    								<tr>
    									<td valign="top" height="35" width="331" colspan="2">
    									<b><font size="2">Room:<br>
    									<input type="checkbox" name="C28" value="ON">King&nbsp;
    									<input type="checkbox" name="C29" value="ON">Double&nbsp;
    									<input type="checkbox" name="C30" value="ON">Smoking&nbsp;
    									<input type="checkbox" name="C31" value="ON">Non-Smoking</font></b></td>
    								</tr>
    								<tr>
    									<td valign="top" height="50" width="331" colspan="2">
    									<b><font size="2"><br>
    									T-Shirt:<br>
    									<input type="checkbox" name="C32" value="ON">XXL&nbsp;
    									<input type="checkbox" name="C33" value="ON">XL&nbsp;
    									<input type="checkbox" name="C34" value="ON">Large&nbsp;
    									<input type="checkbox" name="C35" value="ON">Medium&nbsp;
    									<input type="checkbox" name="C36" value="ON">Small</font></b></td>
    								</tr>
    							</table>
    							</td>
    						</tr>
    					</table>
    					<input type="submit" value="Submit Form" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    					<input type="reset"  value="Reset Form Fields" />
    				<input type="hidden" name="_submit" value="1" />
    				</form>
    			</div>
    			</td>
    		</tr>
    	</table>
    </div>
    <p>&nbsp;</p>
    
    </body>
    
    </html>
    <?php
    ////////////////////////////////////////////////////////////////////////////////
    /**
     * Color the description of a field to red when an error has been found.
     */
    function is_err($field) {
      global $ertags;
      if (in_array($field, $ertags))
         echo " style='color:red;' ";
      else 
         echo "";
    }
    ?>

    If you need the other two files please message me and I can provide them, the error or missing symbol has to be on this page.

    Thanks

    Chris
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    it would be nice to know what errors that are …

    Comment

    • Chrisjc
      Contributor
      • Nov 2006
      • 375

      #3
      Well see that is just it, I am not getting errors... my invalid error part just keeps showing up
      Code:
       <?php
      ////////////////////////////////////////////////////////////////////////////////
      /**
       * Color the description of a field to red when an error has been found.
       */
      function is_err($field) {
        global $ertags;
        if (in_array($field, $ertags))
           echo " style='color:red;' ";
        else 
           echo "";
      }
      ?>
      So in my IF statement it seems to only want to use this line I will attach all three files here. If you could try to run it on your side and let me know what you see that would be great! Also if you think you could finish and let me know a price before you do I will happyly pay you as I need this form ASAP now and I thought I could do it but it seems that I was wrong.

      Comment

      • Chrisjc
        Contributor
        • Nov 2006
        • 375

        #4
        Here are the files I could only upload them in txt.

        Please let me know if you come up with anything

        Thank you!
        Attached Files

        Comment

        • zorgi
          Recognized Expert Contributor
          • Mar 2008
          • 431

          #5
          Well see that is just it, I am not getting errors... my invalid error part just keeps showing up
          They are showing up cos names of your input fields don't match. This is your HTML sample:

          Code:
          <tr>
          <td valign="top" height="37" width="331" colspan="2">
          <font size="2"><b>Guests Name:</b><br>
          <input type="text" name="T16" size="25"></font></td>
           </tr>
          and than in your php you refer to it as:

          Code:
          $_POST['Guests Name']
          When you should refer to it as:
          Code:
          $_POST['T16']

          Comment

          • Chrisjc
            Contributor
            • Nov 2006
            • 375

            #6
            ha! Nice I completely put the wrong names in the $_POSTS you where right!

            Maybe you could help me now figure out why it doesnt highlight the fields?

            Comment

            • zorgi
              Recognized Expert Contributor
              • Mar 2008
              • 431

              #7
              post the code once you fixed the issue with $_POST - s and I'll have a look

              Comment

              • Chrisjc
                Contributor
                • Nov 2006
                • 375

                #8
                Code:
                <html>
                
                <head>
                <meta http-equiv="Content-Language" content="en-us">
                <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
                <title>Players / Foursome</title>
                </head>
                
                <body>
                
                <div align="center">
                	<table border="0" width="44%" height="646">
                		<tr>
                			<td valign="top">
                			<table border="0" width="100%" style="border-bottom-width: 0px">
                				<tr>
                					<td valign="top" style="border-bottom-style: none; border-bottom-width: medium">&nbsp;<b><font size="5">Players 
                					/ Foursome</font></b></td>
                				</tr>
                			</table>
                			<?php
                $errors = array();                        // array to hold error messages
                $ertags = array();                        // array to hold names of erroneous fields
                // ===========================================================================
                // When the form is submitted:
                // a. all fields: 'sanitize' by removing code tags
                // b. mandatory fields: check for validity and content (some)
                // ===========================================================================
                if (isset($_POST['_submit'])) {
                  // ----------------------------------------------------
                  // remove harmful code tags from all $_POST variables
                  // ----------------------------------------------------
                  foreach ($_POST as $key => $val) {
                    $_POST[$key] = trim(strip_tags($val));
                  }
                  // ----------------------------------------------------
                  // Verify existence and content of mandatory fields:
                  //
                  // Golfers Name   			Golfers Name
                  // Guests Name     			Guests Name
                  // Company       				Company
                  // Home Address				Home Address
                  // Phone	      				Phone
                  // Fax      					Fax
                  // Email      				E-mail           (valid e-mail address)
                  // Room						Room
                  // Smoking					Smoking
                  // Shirt						Shirt
                  // ----------------------------------------------------
                  //
                  // Golfers Name
                  if (!isset($_POST['P1GN']) OR $_POST['P1GN'] == '') {
                     $errors[] = "Golfers Name invalid";
                     $ertags[] = 'Golfers Name';
                  }
                  // Guests Name
                  if (!isset($_POST['P1GUN']) OR $_POST['P1GUN'] == '') {
                     $errors[] = "Guests Name invalid";
                     $ertags[] = 'Guests Name';
                  }
                  // Company
                  if (!isset($_POST['P1C']) OR $_POST['P1C'] == '') {
                     $errors[] = "Company invalid";
                     $ertags[] = 'Company';
                  }
                  // Home Address
                  if (!isset($_POST['P1HA']) OR $_POST['P1HA'] == '') {
                     $errors[] = "Home Address invalid";
                     $ertags[] = 'Home Address';
                  }
                    // Phone
                  if (!isset($_POST['P1P']) OR $_POST['P1P'] == '') {
                     $errors[] = "Phone invalid";
                     $ertags[] = 'Phone';
                  }
                  // Fax
                  if (!isset($_POST['P1F']) OR $_POST['P1F'] == '') {
                     $errors[] = "Fax invalid";
                     $ertags[] = 'Fax';
                  }
                  // Email (check also if valid e-mail address)
                  if (!isset($_POST['P1EM']) OR !preg_match("/^[0-9a-z]+(([\.\-_])[0-9a-z]+)*@[0-9a-z]+(([\.\-])[0-9a-z-]+)*\.[a-z]{2,4}$/i", $_POST['P1EM'])) {
                     $errors[] = "E-mail address invalid";
                     $ertags[] = 'Email';
                     }
                  // Room
                  if (!isset($_POST['P1R']) OR $_POST['P1R'] == '') {
                     $errors[] = "Room invalid";
                     $ertags[] = 'Room';
                  }
                  // Shirt
                  if (!isset($_POST['P1SM']) OR $_POST['P1SM'] == '') {
                     $errors[] = "Shirt invalid";
                     $ertags[] = 'Shirt';
                  }
                  // -------------------------------------------------------
                  // ERRORS FOUND: print out and re-display form
                  // -------------------------------------------------------
                  if ($errors) {
                     echo '<div style="margin-left:250px;font-size:12px;font-family:Tahoma;color:red;">';
                	 echo '<u><b>The following errors were encountered (see highlighted fields):</b></u><ul><li>';
                     echo implode('</li><li>',$errors);
                     echo '</li></ul></div>';
                  }
                  else {
                     // -------------------------------------------------------
                     // NO ERRORS FOUND: continue and construct e-mail message
                     // -------------------------------------------------------
                     // echo '<pre>'; print_r($_POST); echo '<br>'; 
                     include("convertPost.php");
                     exit;
                  }
                  
                } // END if isset _submitted
                // ==================================================================================
                // (Re) Display the form
                // ==================================================================================
                ?>
                			<hr size="1" color="#000000">
                			<div align="center">
                				<form name="myForm" action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
                					<table border="0" cellspacing="10" cellpadding="3">
                						<tr>
                							<td style="border-style: solid; border-width: 1px" valign="top" width="344">
                							<table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
                								<tr>
                									<td valign="top" height="20" width="331" colspan="2">
                									<p align="center"><b><font size="4">Player 
                									One</font></b></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Golfers Name:</b><br>
                									<input type="text" name="P1GN" size="25" tabindex="1" value="<?php echo (isset($_POST['Golfers Name'])) ? $_POST['Golfers Name'] : ""; ?>"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Guests Name:</b><br>
                									<input type="text" name="P1GUN" size="25" tabindex="2" value="<?php echo (isset($_POST['Guests Name'])) ? $_POST['Guests Name'] : ""; ?>"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Company:</b><br>
                									<input type="text" name="P1C" size="30" tabindex="3" value="<?php echo (isset($_POST['Company'])) ? $_POST['Company'] : ""; ?>"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Home Address:</b><br>
                									<input type="text" name="P1HA" size="48" tabindex="4" value="<?php echo (isset($_POST['Home Address'])) ? $_POST['Home Address'] : ""; ?>"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="175"><b>
                									<font size="2">Phone:<br>
                									</font></b><font size="2">
                									<input type="text" name="P1P" size="20" tabindex="5" value="<?php echo (isset($_POST['Phone'])) ? $_POST['Phone'] : ""; ?>"></font></td>
                									<td valign="top" height="37" width="169">
                									<font size="2"><b>Fax:</b><br>
                									<input type="text" name="P1F" size="20" tabindex="6" value="<?php echo (isset($_POST['Fax'])) ? $_POST['Fax'] : ""; ?>"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Email:</b><br>
                									<input type="text" name="P1EM" size="38" tabindex="7" value="<?php echo (isset($_POST['Email'])) ? $_POST['Email'] : ""; ?>"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="35" width="331" colspan="2">
                									<b><font size="2">Room:<br>
                									<select size="1" name="P1R">
                									<option selected>Select Bed Size</option>
                									<option>King</option>
                									<option>Double</option>
                									<?php echo (isset($_POST['Room'])) ? $_POST['Room'] : ""; ?></select>&nbsp;&nbsp;&nbsp;&nbsp;
                									<select size="1" name="P1SM">
                									<option selected>Smoking or Non-Smoking
                									</option>
                									<option>Smoking</option>
                									<option>Non-Smoking</option>
                									<?php echo (isset($_POST['Smoking'])) ? $_POST['Smoking'] : ""; ?></select></font></b></td>
                								</tr>
                								<tr>
                									<td valign="top" height="50" width="331" colspan="2">
                									<b><font size="2"><br>
                									T-Shirt:<br>
                									<select size="1" name="P1TS">
                									<option selected>Select Your Size</option>
                									<option>XXL</option>
                									<option>XL</option>
                									<option>Large</option>
                									<option>Medium</option>
                									<option>Small</option>
                									<?php echo (isset($_POST['Shirt'])) ? $_POST['Shirt'] : ""; ?></select></font></b></td>
                								</tr>
                							</table>
                							</td>
                							<td style="border-style: solid; border-width: 1px" valign="top">
                							<table border="0" width="331" cellspacing="0" cellpadding="0" height="326">
                								<tr>
                									<td valign="top" height="19" width="331" colspan="2">
                									<p align="center"><b><font size="4">Player 
                									Two</font></b></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Golfers Name:</b><br>
                									<input type="text" name="T8" size="25"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Guests Name:</b><br>
                									<input type="text" name="T9" size="25"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Company:</b><br>
                									<input type="text" name="T10" size="30"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Home Address:</b><br>
                									<input type="text" name="T11" size="48"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="174"><b>
                									<font size="2">Phone:<br>
                									</font></b><font size="2">
                									<input type="text" name="T12" size="20"></font></td>
                									<td valign="top" height="37" width="170">
                									<font size="2"><b>Fax:</b><br>
                									<input type="text" name="T13" size="20"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Email:</b><br>
                									<input type="text" name="T14" size="38"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="35" width="331" colspan="2">
                									<b><font size="2">Room:<br>
                									<input type="checkbox" name="C10" value="ON">King&nbsp;
                									<input type="checkbox" name="C11" value="ON">Double&nbsp;
                									<input type="checkbox" name="C12" value="ON">Smoking&nbsp;
                									<input type="checkbox" name="C13" value="ON">Non-Smoking</font></b></td>
                								</tr>
                								<tr>
                									<td valign="top" height="50" width="331" colspan="2">
                									<b><font size="2"><br>
                									T-Shirt:<br>
                									<input type="checkbox" name="C14" value="ON">XXL&nbsp;
                									<input type="checkbox" name="C15" value="ON">XL&nbsp;
                									<input type="checkbox" name="C16" value="ON">Large&nbsp;
                									<input type="checkbox" name="C17" value="ON">Medium&nbsp;
                									<input type="checkbox" name="C18" value="ON">Small</font></b></td>
                								</tr>
                							</table>
                							</td>
                						</tr>
                						<tr>
                							<td style="border-style: solid; border-width: 1px" valign="top" width="344">
                							<table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
                								<tr>
                									<td valign="top" height="20" width="331" colspan="2">
                									<p align="center"><b><font size="4">Player 
                									Three</font></b></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Golfers Name:</b><br>
                									<input type="text" name="T15" size="25"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Guests Name:</b><br>
                									<input type="text" name="T16" size="25"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Company:</b><br>
                									<input type="text" name="T17" size="30"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Home Address:</b><br>
                									<input type="text" name="T18" size="48"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="173"><b>
                									<font size="2">Phone:<br>
                									</font></b><font size="2">
                									<input type="text" name="T19" size="20"></font></td>
                									<td valign="top" height="37" width="171">
                									<font size="2"><b>Fax:</b><br>
                									<input type="text" name="T20" size="20"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Email:</b><br>
                									<input type="text" name="T21" size="38"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="35" width="331" colspan="2">
                									<b><font size="2">Room:<br>
                									<input type="checkbox" name="C19" value="ON">King&nbsp;
                									<input type="checkbox" name="C20" value="ON">Double&nbsp;
                									<input type="checkbox" name="C21" value="ON">Smoking&nbsp;
                									<input type="checkbox" name="C22" value="ON">Non-Smoking</font></b></td>
                								</tr>
                								<tr>
                									<td valign="top" height="50" width="331" colspan="2">
                									<b><font size="2"><br>
                									T-Shirt:<br>
                									<input type="checkbox" name="C23" value="ON">XXL&nbsp;
                									<input type="checkbox" name="C24" value="ON">XL&nbsp;
                									<input type="checkbox" name="C25" value="ON">Large&nbsp;
                									<input type="checkbox" name="C26" value="ON">Medium&nbsp;
                									<input type="checkbox" name="C27" value="ON">Small</font></b></td>
                								</tr>
                							</table>
                							</td>
                							<td style="border-style: solid; border-width: 1px" valign="top">
                							<table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
                								<tr>
                									<td valign="top" height="20" width="331" colspan="2">
                									<p align="center"><b><font size="4">Player 
                									Four</font></b></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Golfers Name:</b><br>
                									<input type="text" name="T22" size="25"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Guests Name:</b><br>
                									<input type="text" name="T23" size="25"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Company:</b><br>
                									<input type="text" name="T24" size="30"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Home Address:</b><br>
                									<input type="text" name="T25" size="48"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="174"><b>
                									<font size="2">Phone:<br>
                									</font></b><font size="2">
                									<input type="text" name="T26" size="20"></font></td>
                									<td valign="top" height="37" width="170">
                									<font size="2"><b>Fax:</b><br>
                									<input type="text" name="T27" size="20"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="37" width="331" colspan="2">
                									<font size="2"><b>Email:</b><br>
                									<input type="text" name="T28" size="38"></font></td>
                								</tr>
                								<tr>
                									<td valign="top" height="35" width="331" colspan="2">
                									<b><font size="2">Room:<br>
                									<input type="checkbox" name="C28" value="ON">King&nbsp;
                									<input type="checkbox" name="C29" value="ON">Double&nbsp;
                									<input type="checkbox" name="C30" value="ON">Smoking&nbsp;
                									<input type="checkbox" name="C31" value="ON">Non-Smoking</font></b></td>
                								</tr>
                								<tr>
                									<td valign="top" height="50" width="331" colspan="2">
                									<b><font size="2"><br>
                									T-Shirt:<br>
                									<input type="checkbox" name="C32" value="ON">XXL&nbsp;
                									<input type="checkbox" name="C33" value="ON">XL&nbsp;
                									<input type="checkbox" name="C34" value="ON">Large&nbsp;
                									<input type="checkbox" name="C35" value="ON">Medium&nbsp;
                									<input type="checkbox" name="C36" value="ON">Small</font></b></td>
                								</tr>
                							</table>
                							</td>
                						</tr>
                					</table>
                					<p><input type="submit" value="Submit Form" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                					<input type="reset" value="Reset Form Fields" name="B2"></p>
                				<input type="hidden" name="_submit" value="1" /></form>
                			</div>
                			</td>
                		</tr>
                	</table>
                </div>
                <p>&nbsp;</p>
                
                </body>
                
                </html>
                <?php
                ////////////////////////////////////////////////////////////////////////////////
                /**
                 * Color the description of a field to red when an error has been found.
                 */
                function is_err($field) {
                  global $ertags;
                  if (in_array($field, $ertags))
                     echo " style='color:red;' ";
                  else 
                     echo "";
                }
                ?>
                Last edited by Dormilich; Feb 1 '10, 07:36 PM. Reason: Please use [code] tags when posting code

                Comment

                • zorgi
                  Recognized Expert Contributor
                  • Mar 2008
                  • 431

                  #9
                  Correct me if I'm wrong but you posted the same thing again!?

                  Comment

                  • Chrisjc
                    Contributor
                    • Nov 2006
                    • 375

                    #10
                    Another thing I am noticing here, is that it is not holding the values in the form if I hit submit and there is a field that is blank, it will show the error for that field but than all other values are gone. Any ideas on that too?

                    Comment

                    • Chrisjc
                      Contributor
                      • Nov 2006
                      • 375

                      #11
                      No the values are changed the form is working correctly now just smaller issues. Ignore all other fields as I am only trying to make the "Player One" form work first than I will add functionality to the rest.

                      Comment

                      • Chrisjc
                        Contributor
                        • Nov 2006
                        • 375

                        #12
                        ahh crap I think I see why now, grr I hate this... not very good at this at all... one sec

                        Comment

                        • Chrisjc
                          Contributor
                          • Nov 2006
                          • 375

                          #13
                          Please Delete the last few posts here is the new code. Having issues with the highlighting and the selected drop down boxes the if statments are wrong.

                          Code:
                          <html>
                          
                          <head>
                          <meta http-equiv="Content-Language" content="en-us">
                          <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
                          <title>Players / Foursome</title>
                          </head>
                          
                          <body>
                          
                          <div align="center">
                          	<table border="0" width="44%" height="646">
                          		<tr>
                          			<td valign="top">
                          			<table border="0" width="100%" style="border-bottom-width: 0px">
                          				<tr>
                          					<td valign="top" style="border-bottom-style: none; border-bottom-width: medium">&nbsp;<b><font size="5">Players 
                          					/ Foursome</font></b></td>
                          				</tr>
                          			</table>
                          			<?php
                          $errors = array();                        // array to hold error messages
                          $ertags = array();                        // array to hold names of erroneous fields
                          // ===========================================================================
                          // When the form is submitted:
                          // a. all fields: 'sanitize' by removing code tags
                          // b. mandatory fields: check for validity and content (some)
                          // ===========================================================================
                          if (isset($_POST['_submit'])) {
                            // ----------------------------------------------------
                            // remove harmful code tags from all $_POST variables
                            // ----------------------------------------------------
                            foreach ($_POST as $key => $val) {
                              $_POST[$key] = trim(strip_tags($val));
                            }
                            // ----------------------------------------------------
                            // Verify existence and content of mandatory fields:
                            //
                            // Golfers Name   			Golfers Name
                            // Guests Name     			Guests Name
                            // Company       				Company
                            // Home Address				Home Address
                            // Phone	      				Phone
                            // Fax      					Fax
                            // Email      				E-mail           (valid e-mail address)
                            // Room						Room
                            // Smoking					Smoking
                            // Shirt						Shirt
                            // ----------------------------------------------------
                            //
                            // Golfers Name
                            if (!isset($_POST['P1GN']) OR $_POST['P1GN'] == '') {
                               $errors[] = "Golfers Name invalid";
                               $ertags[] = 'P1GN';
                            }
                            // Guests Name
                            if (!isset($_POST['P1GUN']) OR $_POST['P1GUN'] == '') {
                               $errors[] = "Guests Name invalid";
                               $ertags[] = 'P1GUN';
                            }
                            // Company
                            if (!isset($_POST['P1C']) OR $_POST['P1C'] == '') {
                               $errors[] = "Company invalid";
                               $ertags[] = 'P1C';
                            }
                            // Home Address
                            if (!isset($_POST['P1HA']) OR $_POST['P1HA'] == '') {
                               $errors[] = "Home Address invalid";
                               $ertags[] = 'P1HA';
                            }
                              // Phone
                            if (!isset($_POST['P1P']) OR $_POST['P1P'] == '') {
                               $errors[] = "Phone invalid";
                               $ertags[] = 'P1P';
                            }
                            // Fax
                            if (!isset($_POST['P1F']) OR $_POST['P1F'] == '') {
                               $errors[] = "Fax invalid";
                               $ertags[] = 'P1F';
                            }
                            // Email (check also if valid e-mail address)
                            if (!isset($_POST['P1EM']) OR !preg_match("/^[0-9a-z]+(([\.\-_])[0-9a-z]+)*@[0-9a-z]+(([\.\-])[0-9a-z-]+)*\.[a-z]{2,4}$/i", $_POST['P1EM'])) {
                               $errors[] = "E-mail address invalid";
                               $ertags[] = 'P1EM';
                               }
                            // Room
                            if (!isset($_POST['P1R']) OR $_POST['P1R'] == '') {
                               $errors[] = "Room invalid";
                               $ertags[] = 'P1R';
                            }
                            // Shirt
                            if (!isset($_POST['P1SM']) OR $_POST['P1SM'] == '') {
                               $errors[] = "Shirt invalid";
                               $ertags[] = 'P1SM';
                            }
                            // -------------------------------------------------------
                            // ERRORS FOUND: print out and re-display form
                            // -------------------------------------------------------
                            if ($errors) {
                               echo '<div style="margin-left:250px;font-size:12px;font-family:Tahoma;color:red;">';
                          	 echo '<u><b>The following errors were encountered (see highlighted fields):</b></u><ul><li>';
                               echo implode('</li><li>',$errors);
                               echo '</li></ul></div>';
                            }
                            else {
                               // -------------------------------------------------------
                               // NO ERRORS FOUND: continue and construct e-mail message
                               // -------------------------------------------------------
                               // echo '<pre>'; print_r($_POST); echo '<br>'; 
                               include("convertPost.php");
                               exit;
                            }
                            
                          } // END if isset _submitted
                          // ==================================================================================
                          // (Re) Display the form
                          // ==================================================================================
                          ?>
                          			<hr size="1" color="#000000">
                          			<div align="center">
                          				<form name="myForm" action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
                          					<table border="0" cellspacing="10" cellpadding="3">
                          						<tr>
                          							<td style="border-style: solid; border-width: 1px" valign="top" width="344">
                          							<table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
                          								<tr>
                          									<td valign="top" height="20" width="331" colspan="2">
                          									<p align="center"><b><font size="4">Player 
                          									One</font></b></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Golfers Name:</b><br>
                          									<input type="text" name="P1GN" size="25" tabindex="1" value="<?php echo (isset($_POST['P1GN'])) ? $_POST['P1GN'] : ""; ?>"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Guests Name:</b><br>
                          									<input type="text" name="P1GUN" size="25" tabindex="2" value="<?php echo (isset($_POST['P1GUN'])) ? $_POST['P1GUN'] : ""; ?>"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Company:</b><br>
                          									<input type="text" name="P1C" size="30" tabindex="3" value="<?php echo (isset($_POST['P1GUN'])) ? $_POST['P1GUN'] : ""; ?>"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Home Address:</b><br>
                          									<input type="text" name="P1HA" size="48" tabindex="4" value="<?php echo (isset($_POST['P1HA'])) ? $_POST['P1HA'] : ""; ?>"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="175"><b>
                          									<font size="2">Phone:<br>
                          									</font></b><font size="2">
                          									<input type="text" name="P1P" size="20" tabindex="5" value="<?php echo (isset($_POST['P1P'])) ? $_POST['P1P'] : ""; ?>"></font></td>
                          									<td valign="top" height="37" width="169">
                          									<font size="2"><b>Fax:</b><br>
                          									<input type="text" name="P1F" size="20" tabindex="6" value="<?php echo (isset($_POST['P1F'])) ? $_POST['P1F'] : ""; ?>"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Email:</b><br>
                          									<input type="text" name="P1EM" size="38" tabindex="7" value="<?php echo (isset($_POST['P1EMl'])) ? $_POST['P1EMl'] : ""; ?>"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="35" width="331" colspan="2">
                          									<b><font size="2">Room:<br>
                          									<select size="1" name="P1R">
                          									<option selected>Select Bed Size</option>
                          									<option>King</option>
                          									<option>Double</option>
                          									<?php echo (isset($_POST['P1R'])) ? $_POST['P1R'] : ""; ?></select>&nbsp;&nbsp;&nbsp;&nbsp;
                          									<select size="1" name="P1SM">
                          									<option selected>Smoking or Non-Smoking
                          									</option>
                          									<option>Smoking</option>
                          									<option>Non-Smoking</option>
                          									<?php echo (isset($_POST['P1SM'])) ? $_POST['P1SM'] : ""; ?></select></font></b></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="50" width="331" colspan="2">
                          									<b><font size="2"><br>
                          									T-Shirt:<br>
                          									<select size="1" name="P1TS">
                          									<option selected>Select Your Size</option>
                          									<option>XXL</option>
                          									<option>XL</option>
                          									<option>Large</option>
                          									<option>Medium</option>
                          									<option>Small</option>
                          									<?php echo (isset($_POST['P1TS'])) ? $_POST['P1TS'] : ""; ?></select></font></b></td>
                          								</tr>
                          							</table>
                          							</td>
                          							<td style="border-style: solid; border-width: 1px" valign="top">
                          							<table border="0" width="331" cellspacing="0" cellpadding="0" height="326">
                          								<tr>
                          									<td valign="top" height="19" width="331" colspan="2">
                          									<p align="center"><b><font size="4">Player 
                          									Two</font></b></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Golfers Name:</b><br>
                          									<input type="text" name="T8" size="25"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Guests Name:</b><br>
                          									<input type="text" name="T9" size="25"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Company:</b><br>
                          									<input type="text" name="T10" size="30"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Home Address:</b><br>
                          									<input type="text" name="T11" size="48"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="174"><b>
                          									<font size="2">Phone:<br>
                          									</font></b><font size="2">
                          									<input type="text" name="T12" size="20"></font></td>
                          									<td valign="top" height="37" width="170">
                          									<font size="2"><b>Fax:</b><br>
                          									<input type="text" name="T13" size="20"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Email:</b><br>
                          									<input type="text" name="T14" size="38"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="35" width="331" colspan="2">
                          									<b><font size="2">Room:<br>
                          									<input type="checkbox" name="C10" value="ON">King&nbsp;
                          									<input type="checkbox" name="C11" value="ON">Double&nbsp;
                          									<input type="checkbox" name="C12" value="ON">Smoking&nbsp;
                          									<input type="checkbox" name="C13" value="ON">Non-Smoking</font></b></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="50" width="331" colspan="2">
                          									<b><font size="2"><br>
                          									T-Shirt:<br>
                          									<input type="checkbox" name="C14" value="ON">XXL&nbsp;
                          									<input type="checkbox" name="C15" value="ON">XL&nbsp;
                          									<input type="checkbox" name="C16" value="ON">Large&nbsp;
                          									<input type="checkbox" name="C17" value="ON">Medium&nbsp;
                          									<input type="checkbox" name="C18" value="ON">Small</font></b></td>
                          								</tr>
                          							</table>
                          							</td>
                          						</tr>
                          						<tr>
                          							<td style="border-style: solid; border-width: 1px" valign="top" width="344">
                          							<table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
                          								<tr>
                          									<td valign="top" height="20" width="331" colspan="2">
                          									<p align="center"><b><font size="4">Player 
                          									Three</font></b></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Golfers Name:</b><br>
                          									<input type="text" name="T15" size="25"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Guests Name:</b><br>
                          									<input type="text" name="T16" size="25"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Company:</b><br>
                          									<input type="text" name="T17" size="30"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Home Address:</b><br>
                          									<input type="text" name="T18" size="48"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="173"><b>
                          									<font size="2">Phone:<br>
                          									</font></b><font size="2">
                          									<input type="text" name="T19" size="20"></font></td>
                          									<td valign="top" height="37" width="171">
                          									<font size="2"><b>Fax:</b><br>
                          									<input type="text" name="T20" size="20"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Email:</b><br>
                          									<input type="text" name="T21" size="38"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="35" width="331" colspan="2">
                          									<b><font size="2">Room:<br>
                          									<input type="checkbox" name="C19" value="ON">King&nbsp;
                          									<input type="checkbox" name="C20" value="ON">Double&nbsp;
                          									<input type="checkbox" name="C21" value="ON">Smoking&nbsp;
                          									<input type="checkbox" name="C22" value="ON">Non-Smoking</font></b></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="50" width="331" colspan="2">
                          									<b><font size="2"><br>
                          									T-Shirt:<br>
                          									<input type="checkbox" name="C23" value="ON">XXL&nbsp;
                          									<input type="checkbox" name="C24" value="ON">XL&nbsp;
                          									<input type="checkbox" name="C25" value="ON">Large&nbsp;
                          									<input type="checkbox" name="C26" value="ON">Medium&nbsp;
                          									<input type="checkbox" name="C27" value="ON">Small</font></b></td>
                          								</tr>
                          							</table>
                          							</td>
                          							<td style="border-style: solid; border-width: 1px" valign="top">
                          							<table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
                          								<tr>
                          									<td valign="top" height="20" width="331" colspan="2">
                          									<p align="center"><b><font size="4">Player 
                          									Four</font></b></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Golfers Name:</b><br>
                          									<input type="text" name="T22" size="25"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Guests Name:</b><br>
                          									<input type="text" name="T23" size="25"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Company:</b><br>
                          									<input type="text" name="T24" size="30"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Home Address:</b><br>
                          									<input type="text" name="T25" size="48"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="174"><b>
                          									<font size="2">Phone:<br>
                          									</font></b><font size="2">
                          									<input type="text" name="T26" size="20"></font></td>
                          									<td valign="top" height="37" width="170">
                          									<font size="2"><b>Fax:</b><br>
                          									<input type="text" name="T27" size="20"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="37" width="331" colspan="2">
                          									<font size="2"><b>Email:</b><br>
                          									<input type="text" name="T28" size="38"></font></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="35" width="331" colspan="2">
                          									<b><font size="2">Room:<br>
                          									<input type="checkbox" name="C28" value="ON">King&nbsp;
                          									<input type="checkbox" name="C29" value="ON">Double&nbsp;
                          									<input type="checkbox" name="C30" value="ON">Smoking&nbsp;
                          									<input type="checkbox" name="C31" value="ON">Non-Smoking</font></b></td>
                          								</tr>
                          								<tr>
                          									<td valign="top" height="50" width="331" colspan="2">
                          									<b><font size="2"><br>
                          									T-Shirt:<br>
                          									<input type="checkbox" name="C32" value="ON">XXL&nbsp;
                          									<input type="checkbox" name="C33" value="ON">XL&nbsp;
                          									<input type="checkbox" name="C34" value="ON">Large&nbsp;
                          									<input type="checkbox" name="C35" value="ON">Medium&nbsp;
                          									<input type="checkbox" name="C36" value="ON">Small</font></b></td>
                          								</tr>
                          							</table>
                          							</td>
                          						</tr>
                          					</table>
                          					<p><input type="submit" value="Submit Form" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                          					<input type="reset" value="Reset Form Fields" name="B2"></p>
                          				<input type="hidden" name="_submit" value="1" /></form>
                          			</div>
                          			</td>
                          		</tr>
                          	</table>
                          </div>
                          <p>&nbsp;</p>
                          
                          </body>
                          
                          </html>
                          <?php
                          ////////////////////////////////////////////////////////////////////////////////
                          /**
                           * Color the description of a field to red when an error has been found.
                           */
                          function is_err($field) {
                            global $ertags;
                            if (in_array($field, $ertags))
                               echo " style='color:red;' ";
                            else 
                               echo "";
                          }
                          ?>
                          How would I correct the statments to check if they selected an option

                          Code:
                            // Room
                            if (!isset($_POST['P1R']) OR $_POST['P1R'] == '') {
                               $errors[] = "Room invalid";
                               $ertags[] = 'P1R';
                            }
                            // Shirt
                            if (!isset($_POST['P1SM']) OR $_POST['P1SM'] == '') {
                               $errors[] = "Shirt invalid";
                               $ertags[] = 'P1SM';

                          Comment

                          • zorgi
                            Recognized Expert Contributor
                            • Mar 2008
                            • 431

                            #14
                            This is your code:

                            Code:
                            <select size="1" name="P1R">
                            <option selected>Select Bed Size</option>
                            <option>King</option>
                            <option>Double</option>
                            <?php echo (isset($_POST['P1R'])) ? $_POST['P1R'] : ""; ?></select>
                            Your options don't have values?! You should give them values like this:

                            Code:
                            <select size="1" name="P1R">
                            <option value="">Select Bed Size</option>
                            <option value="king">King</option>
                            <option value="double">Double</option>
                            </select>
                            Only now they have some use. Now you can add php too:

                            Code:
                            <select size="1" name="P1R">
                            <option value="">Select Bed Size</option>
                            <option value="king" <?php echo ($_POST['P1R'] == "king")?("selected"):(""); ?>>King</option>
                            <option value="double" <?php echo ($_POST['P1R'] == "double")?("selected"):(""); ?>>Double</option>
                            </select>
                            And as far as highlighting goes and why it doesn't highlight, well ... I do not see any reason in your code that would suggest that it should.

                            Comment

                            Working...