473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Form Issue

Chrisjc
375 256MB
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?

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4. <meta http-equiv="Content-Language" content="en-us">
  5. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  6. <title>Players / Foursome</title>
  7. </head>
  8.  
  9. <body>
  10.  
  11. <div align="center">
  12.     <table border="0" width="44%" height="646">
  13.         <tr>
  14.             <td valign="top">
  15.             <table border="0" width="100%" style="border-bottom-width: 0px">
  16.                 <tr>
  17.                     <td valign="top" style="border-bottom-style: none; border-bottom-width: medium">&nbsp;<b><font size="5">Players 
  18.                     / Foursome</font></b></td>
  19.                 </tr>
  20.             </table>
  21.             <?php
  22. $errors = array();                        // array to hold error messages
  23. $ertags = array();                        // array to hold names of erroneous fields
  24. // ===========================================================================
  25. // When the form is submitted:
  26. // a. all fields: 'sanitize' by removing code tags
  27. // b. mandatory fields: check for validity and content (some)
  28. // ===========================================================================
  29. if (isset($_POST['_submit'])) {
  30.   // ----------------------------------------------------
  31.   // remove harmful code tags from all $_POST variables
  32.   // ----------------------------------------------------
  33.   foreach ($_POST as $key => $val) {
  34.     $_POST[$key] = trim(strip_tags($val));
  35.   }
  36.   // ----------------------------------------------------
  37.   // Verify existence and content of mandatory fields:
  38.   //
  39.   // Golfers Name               Golfers Name
  40.   // Guests Name                 Guests Name
  41.   // Company                       Company
  42.   // Home Address                Home Address
  43.   // Phone                          Phone
  44.   // Fax                          Fax
  45.   // Email                      E-mail           (valid e-mail address)
  46.   // Room                        Room
  47.   // Smoking                    Smoking
  48.   // Shirt                        Shirt
  49.   // ----------------------------------------------------
  50.   //
  51.   // Golfers Name
  52.   if (!isset($_POST['Golfers Name']) OR $_POST['Golfers Name'] == '') {
  53.      $errors[] = "Golfers Name invalid";
  54.      $ertags[] = 'Golfers Name';
  55.   }
  56.   // Guests Name
  57.   if (!isset($_POST['Guests Name']) OR $_POST['Guests Name'] == '') {
  58.      $errors[] = "Guests Name invalid";
  59.      $ertags[] = 'Guests Name';
  60.   }
  61.   // Company
  62.   if (!isset($_POST['Company']) OR $_POST['Company'] == '') {
  63.      $errors[] = "Company invalid";
  64.      $ertags[] = 'Company';
  65.   }
  66.   // Home Address
  67.   if (!isset($_POST['Home Address']) OR $_POST['Home Address'] == '') {
  68.      $errors[] = "Home Address invalid";
  69.      $ertags[] = 'Home Address';
  70.   }
  71.     // Phone
  72.   if (!isset($_POST['Phone']) OR $_POST['Phone'] == '') {
  73.      $errors[] = "Phone invalid";
  74.      $ertags[] = 'Phone';
  75.   }
  76.   // Fax
  77.   if (!isset($_POST['Fax']) OR $_POST['Fax'] == '') {
  78.      $errors[] = "Fax invalid";
  79.      $ertags[] = 'Fax';
  80.   }
  81.   // Email (check also if valid e-mail address)
  82.   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'])) {
  83.      $errors[] = "E-mail address invalid";
  84.      $ertags[] = 'Email';
  85.      }
  86.   // Room
  87.   if (!isset($_POST['Room']) OR $_POST['Room'] == '') {
  88.      $errors[] = "Room invalid";
  89.      $ertags[] = 'Room';
  90.   }
  91.   // Shirt
  92.   if (!isset($_POST['Shirt']) OR $_POST['Shirt'] == '') {
  93.      $errors[] = "Shirt invalid";
  94.      $ertags[] = 'Shirt';
  95.   }
  96.   // -------------------------------------------------------
  97.   // ERRORS FOUND: print out and re-display form
  98.   // -------------------------------------------------------
  99.   if ($errors) {
  100.      echo '<div style="margin-left:250px;font-size:12px;font-family:Tahoma;color:red;">';
  101.      echo '<u><b>The following errors were encountered (see highlighted fields):</b></u><ul><li>';
  102.      echo implode('</li><li>',$errors);
  103.      echo '</li></ul></div>';
  104.   }
  105.   else {
  106.      // -------------------------------------------------------
  107.      // NO ERRORS FOUND: continue and construct e-mail message
  108.      // -------------------------------------------------------
  109.      // echo '<pre>'; print_r($_POST); echo '<br>'; 
  110.      include("convertPost.php");
  111.      exit;
  112.   }
  113.  
  114. } // END if isset _submitted
  115. // ==================================================================================
  116. // (Re) Display the form
  117. // ==================================================================================
  118. ?>
  119.             <hr size="1" color="#000000">
  120.             <div align="center">
  121.                 <form name="myForm" action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
  122.                     <table border="0" cellspacing="10" cellpadding="3">
  123.                         <tr>
  124.                             <td style="border-style: solid; border-width: 1px" valign="top" width="344">
  125.                             <table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
  126.                                 <tr>
  127.                                     <td valign="top" height="20" width="331" colspan="2">
  128.                                     <p align="center"><b><font size="4">Player 
  129.                                     One</font></b></td>
  130.                                 </tr>
  131.                                 <tr>
  132.                                     <td valign="top" height="37" width="331" colspan="2">
  133.                                     <font size="2"><b>Golfers Name:</b><br>
  134.                                     <input type="text" name="P1GN" size="25" tabindex="1" value="<?php echo (isset($_POST['Golfers Name'])) ? $_POST['Golfers Name'] : ""; ?>"></font></td>
  135.                                 </tr>
  136.                                 <tr>
  137.                                     <td valign="top" height="37" width="331" colspan="2">
  138.                                     <font size="2"><b>Guests Name:</b><br>
  139.                                     <input type="text" name="P1GUN" size="25" tabindex="2" value="<?php echo (isset($_POST['Guests Name'])) ? $_POST['Guests Name'] : ""; ?>"></font></td>
  140.                                 </tr>
  141.                                 <tr>
  142.                                     <td valign="top" height="37" width="331" colspan="2">
  143.                                     <font size="2"><b>Company:</b><br>
  144.                                     <input type="text" name="P1C" size="30" tabindex="3" value="<?php echo (isset($_POST['Company'])) ? $_POST['Company'] : ""; ?>"></font></td>
  145.                                 </tr>
  146.                                 <tr>
  147.                                     <td valign="top" height="37" width="331" colspan="2">
  148.                                     <font size="2"><b>Home Address:</b><br>
  149.                                     <input type="text" name="P1HA" size="48" tabindex="4" value="<?php echo (isset($_POST['Home Address'])) ? $_POST['Home Address'] : ""; ?>"></font></td>
  150.                                 </tr>
  151.                                 <tr>
  152.                                     <td valign="top" height="37" width="175"><b>
  153.                                     <font size="2">Phone:<br>
  154.                                     </font></b><font size="2">
  155.                                     <input type="text" name="P1P" size="20" tabindex="5" value="<?php echo (isset($_POST['Phone'])) ? $_POST['Phone'] : ""; ?>"></font></td>
  156.                                     <td valign="top" height="37" width="169">
  157.                                     <font size="2"><b>Fax:</b><br>
  158.                                     <input type="text" name="P1F" size="20" tabindex="6" value="<?php echo (isset($_POST['Fax'])) ? $_POST['Fax'] : ""; ?>"></font></td>
  159.                                 </tr>
  160.                                 <tr>
  161.                                     <td valign="top" height="37" width="331" colspan="2">
  162.                                     <font size="2"><b>Email:</b><br>
  163.                                     <input type="text" name="P1EM" size="38" tabindex="7" value="<?php echo (isset($_POST['Email'])) ? $_POST['Email'] : ""; ?>"></font></td>
  164.                                 </tr>
  165.                                 <tr>
  166.                                     <td valign="top" height="35" width="331" colspan="2">
  167.                                     <b><font size="2">Room:<br>
  168.                                     <select size="1" name="P1R">
  169.                                     <option selected>Select Bed Size</option>
  170.                                     <option>King</option>
  171.                                     <option>Double</option>
  172.                                     <?php echo (isset($_POST['Room'])) ? $_POST['Room'] : ""; ?></select>&nbsp;&nbsp;&nbsp;&nbsp;
  173.                                     <select size="1" name="P1SM">
  174.                                     <option selected>Smoking or Non-Smoking
  175.                                     </option>
  176.                                     <option>Smoking</option>
  177.                                     <option>Non-Smoking</option>
  178.                                     <?php echo (isset($_POST['Smoking'])) ? $_POST['Smoking'] : ""; ?></select></font></b></td>
  179.                                 </tr>
  180.                                 <tr>
  181.                                     <td valign="top" height="50" width="331" colspan="2">
  182.                                     <b><font size="2"><br>
  183.                                     T-Shirt:<br>
  184.                                     <select size="1" name="P1TS">
  185.                                     <option selected>Select Your Size</option>
  186.                                     <option>XXL</option>
  187.                                     <option>XL</option>
  188.                                     <option>Large</option>
  189.                                     <option>Medium</option>
  190.                                     <option>Small</option>
  191.                                     <?php echo (isset($_POST['Shirt'])) ? $_POST['Shirt'] : ""; ?></select></font></b></td>
  192.                                 </tr>
  193.                             </table>
  194.                             </td>
  195.                             <td style="border-style: solid; border-width: 1px" valign="top">
  196.                             <table border="0" width="331" cellspacing="0" cellpadding="0" height="326">
  197.                                 <tr>
  198.                                     <td valign="top" height="19" width="331" colspan="2">
  199.                                     <p align="center"><b><font size="4">Player 
  200.                                     Two</font></b></td>
  201.                                 </tr>
  202.                                 <tr>
  203.                                     <td valign="top" height="37" width="331" colspan="2">
  204.                                     <font size="2"><b>Golfers Name:</b><br>
  205.                                     <input type="text" name="T8" size="25"></font></td>
  206.                                 </tr>
  207.                                 <tr>
  208.                                     <td valign="top" height="37" width="331" colspan="2">
  209.                                     <font size="2"><b>Guests Name:</b><br>
  210.                                     <input type="text" name="T9" size="25"></font></td>
  211.                                 </tr>
  212.                                 <tr>
  213.                                     <td valign="top" height="37" width="331" colspan="2">
  214.                                     <font size="2"><b>Company:</b><br>
  215.                                     <input type="text" name="T10" size="30"></font></td>
  216.                                 </tr>
  217.                                 <tr>
  218.                                     <td valign="top" height="37" width="331" colspan="2">
  219.                                     <font size="2"><b>Home Address:</b><br>
  220.                                     <input type="text" name="T11" size="48"></font></td>
  221.                                 </tr>
  222.                                 <tr>
  223.                                     <td valign="top" height="37" width="174"><b>
  224.                                     <font size="2">Phone:<br>
  225.                                     </font></b><font size="2">
  226.                                     <input type="text" name="T12" size="20"></font></td>
  227.                                     <td valign="top" height="37" width="170">
  228.                                     <font size="2"><b>Fax:</b><br>
  229.                                     <input type="text" name="T13" size="20"></font></td>
  230.                                 </tr>
  231.                                 <tr>
  232.                                     <td valign="top" height="37" width="331" colspan="2">
  233.                                     <font size="2"><b>Email:</b><br>
  234.                                     <input type="text" name="T14" size="38"></font></td>
  235.                                 </tr>
  236.                                 <tr>
  237.                                     <td valign="top" height="35" width="331" colspan="2">
  238.                                     <b><font size="2">Room:<br>
  239.                                     <input type="checkbox" name="C10" value="ON">King&nbsp;
  240.                                     <input type="checkbox" name="C11" value="ON">Double&nbsp;
  241.                                     <input type="checkbox" name="C12" value="ON">Smoking&nbsp;
  242.                                     <input type="checkbox" name="C13" value="ON">Non-Smoking</font></b></td>
  243.                                 </tr>
  244.                                 <tr>
  245.                                     <td valign="top" height="50" width="331" colspan="2">
  246.                                     <b><font size="2"><br>
  247.                                     T-Shirt:<br>
  248.                                     <input type="checkbox" name="C14" value="ON">XXL&nbsp;
  249.                                     <input type="checkbox" name="C15" value="ON">XL&nbsp;
  250.                                     <input type="checkbox" name="C16" value="ON">Large&nbsp;
  251.                                     <input type="checkbox" name="C17" value="ON">Medium&nbsp;
  252.                                     <input type="checkbox" name="C18" value="ON">Small</font></b></td>
  253.                                 </tr>
  254.                             </table>
  255.                             </td>
  256.                         </tr>
  257.                         <tr>
  258.                             <td style="border-style: solid; border-width: 1px" valign="top" width="344">
  259.                             <table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
  260.                                 <tr>
  261.                                     <td valign="top" height="20" width="331" colspan="2">
  262.                                     <p align="center"><b><font size="4">Player 
  263.                                     Three</font></b></td>
  264.                                 </tr>
  265.                                 <tr>
  266.                                     <td valign="top" height="37" width="331" colspan="2">
  267.                                     <font size="2"><b>Golfers Name:</b><br>
  268.                                     <input type="text" name="T15" size="25"></font></td>
  269.                                 </tr>
  270.                                 <tr>
  271.                                     <td valign="top" height="37" width="331" colspan="2">
  272.                                     <font size="2"><b>Guests Name:</b><br>
  273.                                     <input type="text" name="T16" size="25"></font></td>
  274.                                 </tr>
  275.                                 <tr>
  276.                                     <td valign="top" height="37" width="331" colspan="2">
  277.                                     <font size="2"><b>Company:</b><br>
  278.                                     <input type="text" name="T17" size="30"></font></td>
  279.                                 </tr>
  280.                                 <tr>
  281.                                     <td valign="top" height="37" width="331" colspan="2">
  282.                                     <font size="2"><b>Home Address:</b><br>
  283.                                     <input type="text" name="T18" size="48"></font></td>
  284.                                 </tr>
  285.                                 <tr>
  286.                                     <td valign="top" height="37" width="173"><b>
  287.                                     <font size="2">Phone:<br>
  288.                                     </font></b><font size="2">
  289.                                     <input type="text" name="T19" size="20"></font></td>
  290.                                     <td valign="top" height="37" width="171">
  291.                                     <font size="2"><b>Fax:</b><br>
  292.                                     <input type="text" name="T20" size="20"></font></td>
  293.                                 </tr>
  294.                                 <tr>
  295.                                     <td valign="top" height="37" width="331" colspan="2">
  296.                                     <font size="2"><b>Email:</b><br>
  297.                                     <input type="text" name="T21" size="38"></font></td>
  298.                                 </tr>
  299.                                 <tr>
  300.                                     <td valign="top" height="35" width="331" colspan="2">
  301.                                     <b><font size="2">Room:<br>
  302.                                     <input type="checkbox" name="C19" value="ON">King&nbsp;
  303.                                     <input type="checkbox" name="C20" value="ON">Double&nbsp;
  304.                                     <input type="checkbox" name="C21" value="ON">Smoking&nbsp;
  305.                                     <input type="checkbox" name="C22" value="ON">Non-Smoking</font></b></td>
  306.                                 </tr>
  307.                                 <tr>
  308.                                     <td valign="top" height="50" width="331" colspan="2">
  309.                                     <b><font size="2"><br>
  310.                                     T-Shirt:<br>
  311.                                     <input type="checkbox" name="C23" value="ON">XXL&nbsp;
  312.                                     <input type="checkbox" name="C24" value="ON">XL&nbsp;
  313.                                     <input type="checkbox" name="C25" value="ON">Large&nbsp;
  314.                                     <input type="checkbox" name="C26" value="ON">Medium&nbsp;
  315.                                     <input type="checkbox" name="C27" value="ON">Small</font></b></td>
  316.                                 </tr>
  317.                             </table>
  318.                             </td>
  319.                             <td style="border-style: solid; border-width: 1px" valign="top">
  320.                             <table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
  321.                                 <tr>
  322.                                     <td valign="top" height="20" width="331" colspan="2">
  323.                                     <p align="center"><b><font size="4">Player 
  324.                                     Four</font></b></td>
  325.                                 </tr>
  326.                                 <tr>
  327.                                     <td valign="top" height="37" width="331" colspan="2">
  328.                                     <font size="2"><b>Golfers Name:</b><br>
  329.                                     <input type="text" name="T22" size="25"></font></td>
  330.                                 </tr>
  331.                                 <tr>
  332.                                     <td valign="top" height="37" width="331" colspan="2">
  333.                                     <font size="2"><b>Guests Name:</b><br>
  334.                                     <input type="text" name="T23" size="25"></font></td>
  335.                                 </tr>
  336.                                 <tr>
  337.                                     <td valign="top" height="37" width="331" colspan="2">
  338.                                     <font size="2"><b>Company:</b><br>
  339.                                     <input type="text" name="T24" size="30"></font></td>
  340.                                 </tr>
  341.                                 <tr>
  342.                                     <td valign="top" height="37" width="331" colspan="2">
  343.                                     <font size="2"><b>Home Address:</b><br>
  344.                                     <input type="text" name="T25" size="48"></font></td>
  345.                                 </tr>
  346.                                 <tr>
  347.                                     <td valign="top" height="37" width="174"><b>
  348.                                     <font size="2">Phone:<br>
  349.                                     </font></b><font size="2">
  350.                                     <input type="text" name="T26" size="20"></font></td>
  351.                                     <td valign="top" height="37" width="170">
  352.                                     <font size="2"><b>Fax:</b><br>
  353.                                     <input type="text" name="T27" size="20"></font></td>
  354.                                 </tr>
  355.                                 <tr>
  356.                                     <td valign="top" height="37" width="331" colspan="2">
  357.                                     <font size="2"><b>Email:</b><br>
  358.                                     <input type="text" name="T28" size="38"></font></td>
  359.                                 </tr>
  360.                                 <tr>
  361.                                     <td valign="top" height="35" width="331" colspan="2">
  362.                                     <b><font size="2">Room:<br>
  363.                                     <input type="checkbox" name="C28" value="ON">King&nbsp;
  364.                                     <input type="checkbox" name="C29" value="ON">Double&nbsp;
  365.                                     <input type="checkbox" name="C30" value="ON">Smoking&nbsp;
  366.                                     <input type="checkbox" name="C31" value="ON">Non-Smoking</font></b></td>
  367.                                 </tr>
  368.                                 <tr>
  369.                                     <td valign="top" height="50" width="331" colspan="2">
  370.                                     <b><font size="2"><br>
  371.                                     T-Shirt:<br>
  372.                                     <input type="checkbox" name="C32" value="ON">XXL&nbsp;
  373.                                     <input type="checkbox" name="C33" value="ON">XL&nbsp;
  374.                                     <input type="checkbox" name="C34" value="ON">Large&nbsp;
  375.                                     <input type="checkbox" name="C35" value="ON">Medium&nbsp;
  376.                                     <input type="checkbox" name="C36" value="ON">Small</font></b></td>
  377.                                 </tr>
  378.                             </table>
  379.                             </td>
  380.                         </tr>
  381.                     </table>
  382.                     <input type="submit" value="Submit Form" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  383.                     <input type="reset"  value="Reset Form Fields" />
  384.                 <input type="hidden" name="_submit" value="1" />
  385.                 </form>
  386.             </div>
  387.             </td>
  388.         </tr>
  389.     </table>
  390. </div>
  391. <p>&nbsp;</p>
  392.  
  393. </body>
  394.  
  395. </html>
  396. <?php
  397. ////////////////////////////////////////////////////////////////////////////////
  398. /**
  399.  * Color the description of a field to red when an error has been found.
  400.  */
  401. function is_err($field) {
  402.   global $ertags;
  403.   if (in_array($field, $ertags))
  404.      echo " style='color:red;' ";
  405.   else 
  406.      echo "";
  407. }
  408. ?>

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
Jan 29 '10 #1
13 1620
Dormilich
8,658 Expert Mod 8TB
it would be nice to know what errors that are …
Jan 30 '10 #2
Chrisjc
375 256MB
Well see that is just it, I am not getting errors... my invalid error part just keeps showing up
Expand|Select|Wrap|Line Numbers
  1.  <?php
  2. ////////////////////////////////////////////////////////////////////////////////
  3. /**
  4.  * Color the description of a field to red when an error has been found.
  5.  */
  6. function is_err($field) {
  7.   global $ertags;
  8.   if (in_array($field, $ertags))
  9.      echo " style='color:red;' ";
  10.   else 
  11.      echo "";
  12. }
  13. ?> 
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.
Feb 1 '10 #3
Chrisjc
375 256MB
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
File Type: txt indextest.txt (16.4 KB, 330 views)
File Type: txt convertPost.txt (3.7 KB, 321 views)
File Type: txt CconversionTable.txt (2.4 KB, 337 views)
Feb 1 '10 #4
zorgi
431 Expert 256MB
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:

Expand|Select|Wrap|Line Numbers
  1. <tr>
  2. <td valign="top" height="37" width="331" colspan="2">
  3. <font size="2"><b>Guests Name:</b><br>
  4. <input type="text" name="T16" size="25"></font></td>
  5.  </tr>
  6.  
and than in your php you refer to it as:

Expand|Select|Wrap|Line Numbers
  1. $_POST['Guests Name']
  2.  
When you should refer to it as:
Expand|Select|Wrap|Line Numbers
  1. $_POST['T16']
  2.  
Feb 1 '10 #5
Chrisjc
375 256MB
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?
Feb 1 '10 #6
zorgi
431 Expert 256MB
post the code once you fixed the issue with $_POST - s and I'll have a look
Feb 1 '10 #7
Chrisjc
375 256MB
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4. <meta http-equiv="Content-Language" content="en-us">
  5. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  6. <title>Players / Foursome</title>
  7. </head>
  8.  
  9. <body>
  10.  
  11. <div align="center">
  12.     <table border="0" width="44%" height="646">
  13.         <tr>
  14.             <td valign="top">
  15.             <table border="0" width="100%" style="border-bottom-width: 0px">
  16.                 <tr>
  17.                     <td valign="top" style="border-bottom-style: none; border-bottom-width: medium">&nbsp;<b><font size="5">Players 
  18.                     / Foursome</font></b></td>
  19.                 </tr>
  20.             </table>
  21.             <?php
  22. $errors = array();                        // array to hold error messages
  23. $ertags = array();                        // array to hold names of erroneous fields
  24. // ===========================================================================
  25. // When the form is submitted:
  26. // a. all fields: 'sanitize' by removing code tags
  27. // b. mandatory fields: check for validity and content (some)
  28. // ===========================================================================
  29. if (isset($_POST['_submit'])) {
  30.   // ----------------------------------------------------
  31.   // remove harmful code tags from all $_POST variables
  32.   // ----------------------------------------------------
  33.   foreach ($_POST as $key => $val) {
  34.     $_POST[$key] = trim(strip_tags($val));
  35.   }
  36.   // ----------------------------------------------------
  37.   // Verify existence and content of mandatory fields:
  38.   //
  39.   // Golfers Name               Golfers Name
  40.   // Guests Name                 Guests Name
  41.   // Company                       Company
  42.   // Home Address                Home Address
  43.   // Phone                          Phone
  44.   // Fax                          Fax
  45.   // Email                      E-mail           (valid e-mail address)
  46.   // Room                        Room
  47.   // Smoking                    Smoking
  48.   // Shirt                        Shirt
  49.   // ----------------------------------------------------
  50.   //
  51.   // Golfers Name
  52.   if (!isset($_POST['P1GN']) OR $_POST['P1GN'] == '') {
  53.      $errors[] = "Golfers Name invalid";
  54.      $ertags[] = 'Golfers Name';
  55.   }
  56.   // Guests Name
  57.   if (!isset($_POST['P1GUN']) OR $_POST['P1GUN'] == '') {
  58.      $errors[] = "Guests Name invalid";
  59.      $ertags[] = 'Guests Name';
  60.   }
  61.   // Company
  62.   if (!isset($_POST['P1C']) OR $_POST['P1C'] == '') {
  63.      $errors[] = "Company invalid";
  64.      $ertags[] = 'Company';
  65.   }
  66.   // Home Address
  67.   if (!isset($_POST['P1HA']) OR $_POST['P1HA'] == '') {
  68.      $errors[] = "Home Address invalid";
  69.      $ertags[] = 'Home Address';
  70.   }
  71.     // Phone
  72.   if (!isset($_POST['P1P']) OR $_POST['P1P'] == '') {
  73.      $errors[] = "Phone invalid";
  74.      $ertags[] = 'Phone';
  75.   }
  76.   // Fax
  77.   if (!isset($_POST['P1F']) OR $_POST['P1F'] == '') {
  78.      $errors[] = "Fax invalid";
  79.      $ertags[] = 'Fax';
  80.   }
  81.   // Email (check also if valid e-mail address)
  82.   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'])) {
  83.      $errors[] = "E-mail address invalid";
  84.      $ertags[] = 'Email';
  85.      }
  86.   // Room
  87.   if (!isset($_POST['P1R']) OR $_POST['P1R'] == '') {
  88.      $errors[] = "Room invalid";
  89.      $ertags[] = 'Room';
  90.   }
  91.   // Shirt
  92.   if (!isset($_POST['P1SM']) OR $_POST['P1SM'] == '') {
  93.      $errors[] = "Shirt invalid";
  94.      $ertags[] = 'Shirt';
  95.   }
  96.   // -------------------------------------------------------
  97.   // ERRORS FOUND: print out and re-display form
  98.   // -------------------------------------------------------
  99.   if ($errors) {
  100.      echo '<div style="margin-left:250px;font-size:12px;font-family:Tahoma;color:red;">';
  101.      echo '<u><b>The following errors were encountered (see highlighted fields):</b></u><ul><li>';
  102.      echo implode('</li><li>',$errors);
  103.      echo '</li></ul></div>';
  104.   }
  105.   else {
  106.      // -------------------------------------------------------
  107.      // NO ERRORS FOUND: continue and construct e-mail message
  108.      // -------------------------------------------------------
  109.      // echo '<pre>'; print_r($_POST); echo '<br>'; 
  110.      include("convertPost.php");
  111.      exit;
  112.   }
  113.  
  114. } // END if isset _submitted
  115. // ==================================================================================
  116. // (Re) Display the form
  117. // ==================================================================================
  118. ?>
  119.             <hr size="1" color="#000000">
  120.             <div align="center">
  121.                 <form name="myForm" action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
  122.                     <table border="0" cellspacing="10" cellpadding="3">
  123.                         <tr>
  124.                             <td style="border-style: solid; border-width: 1px" valign="top" width="344">
  125.                             <table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
  126.                                 <tr>
  127.                                     <td valign="top" height="20" width="331" colspan="2">
  128.                                     <p align="center"><b><font size="4">Player 
  129.                                     One</font></b></td>
  130.                                 </tr>
  131.                                 <tr>
  132.                                     <td valign="top" height="37" width="331" colspan="2">
  133.                                     <font size="2"><b>Golfers Name:</b><br>
  134.                                     <input type="text" name="P1GN" size="25" tabindex="1" value="<?php echo (isset($_POST['Golfers Name'])) ? $_POST['Golfers Name'] : ""; ?>"></font></td>
  135.                                 </tr>
  136.                                 <tr>
  137.                                     <td valign="top" height="37" width="331" colspan="2">
  138.                                     <font size="2"><b>Guests Name:</b><br>
  139.                                     <input type="text" name="P1GUN" size="25" tabindex="2" value="<?php echo (isset($_POST['Guests Name'])) ? $_POST['Guests Name'] : ""; ?>"></font></td>
  140.                                 </tr>
  141.                                 <tr>
  142.                                     <td valign="top" height="37" width="331" colspan="2">
  143.                                     <font size="2"><b>Company:</b><br>
  144.                                     <input type="text" name="P1C" size="30" tabindex="3" value="<?php echo (isset($_POST['Company'])) ? $_POST['Company'] : ""; ?>"></font></td>
  145.                                 </tr>
  146.                                 <tr>
  147.                                     <td valign="top" height="37" width="331" colspan="2">
  148.                                     <font size="2"><b>Home Address:</b><br>
  149.                                     <input type="text" name="P1HA" size="48" tabindex="4" value="<?php echo (isset($_POST['Home Address'])) ? $_POST['Home Address'] : ""; ?>"></font></td>
  150.                                 </tr>
  151.                                 <tr>
  152.                                     <td valign="top" height="37" width="175"><b>
  153.                                     <font size="2">Phone:<br>
  154.                                     </font></b><font size="2">
  155.                                     <input type="text" name="P1P" size="20" tabindex="5" value="<?php echo (isset($_POST['Phone'])) ? $_POST['Phone'] : ""; ?>"></font></td>
  156.                                     <td valign="top" height="37" width="169">
  157.                                     <font size="2"><b>Fax:</b><br>
  158.                                     <input type="text" name="P1F" size="20" tabindex="6" value="<?php echo (isset($_POST['Fax'])) ? $_POST['Fax'] : ""; ?>"></font></td>
  159.                                 </tr>
  160.                                 <tr>
  161.                                     <td valign="top" height="37" width="331" colspan="2">
  162.                                     <font size="2"><b>Email:</b><br>
  163.                                     <input type="text" name="P1EM" size="38" tabindex="7" value="<?php echo (isset($_POST['Email'])) ? $_POST['Email'] : ""; ?>"></font></td>
  164.                                 </tr>
  165.                                 <tr>
  166.                                     <td valign="top" height="35" width="331" colspan="2">
  167.                                     <b><font size="2">Room:<br>
  168.                                     <select size="1" name="P1R">
  169.                                     <option selected>Select Bed Size</option>
  170.                                     <option>King</option>
  171.                                     <option>Double</option>
  172.                                     <?php echo (isset($_POST['Room'])) ? $_POST['Room'] : ""; ?></select>&nbsp;&nbsp;&nbsp;&nbsp;
  173.                                     <select size="1" name="P1SM">
  174.                                     <option selected>Smoking or Non-Smoking
  175.                                     </option>
  176.                                     <option>Smoking</option>
  177.                                     <option>Non-Smoking</option>
  178.                                     <?php echo (isset($_POST['Smoking'])) ? $_POST['Smoking'] : ""; ?></select></font></b></td>
  179.                                 </tr>
  180.                                 <tr>
  181.                                     <td valign="top" height="50" width="331" colspan="2">
  182.                                     <b><font size="2"><br>
  183.                                     T-Shirt:<br>
  184.                                     <select size="1" name="P1TS">
  185.                                     <option selected>Select Your Size</option>
  186.                                     <option>XXL</option>
  187.                                     <option>XL</option>
  188.                                     <option>Large</option>
  189.                                     <option>Medium</option>
  190.                                     <option>Small</option>
  191.                                     <?php echo (isset($_POST['Shirt'])) ? $_POST['Shirt'] : ""; ?></select></font></b></td>
  192.                                 </tr>
  193.                             </table>
  194.                             </td>
  195.                             <td style="border-style: solid; border-width: 1px" valign="top">
  196.                             <table border="0" width="331" cellspacing="0" cellpadding="0" height="326">
  197.                                 <tr>
  198.                                     <td valign="top" height="19" width="331" colspan="2">
  199.                                     <p align="center"><b><font size="4">Player 
  200.                                     Two</font></b></td>
  201.                                 </tr>
  202.                                 <tr>
  203.                                     <td valign="top" height="37" width="331" colspan="2">
  204.                                     <font size="2"><b>Golfers Name:</b><br>
  205.                                     <input type="text" name="T8" size="25"></font></td>
  206.                                 </tr>
  207.                                 <tr>
  208.                                     <td valign="top" height="37" width="331" colspan="2">
  209.                                     <font size="2"><b>Guests Name:</b><br>
  210.                                     <input type="text" name="T9" size="25"></font></td>
  211.                                 </tr>
  212.                                 <tr>
  213.                                     <td valign="top" height="37" width="331" colspan="2">
  214.                                     <font size="2"><b>Company:</b><br>
  215.                                     <input type="text" name="T10" size="30"></font></td>
  216.                                 </tr>
  217.                                 <tr>
  218.                                     <td valign="top" height="37" width="331" colspan="2">
  219.                                     <font size="2"><b>Home Address:</b><br>
  220.                                     <input type="text" name="T11" size="48"></font></td>
  221.                                 </tr>
  222.                                 <tr>
  223.                                     <td valign="top" height="37" width="174"><b>
  224.                                     <font size="2">Phone:<br>
  225.                                     </font></b><font size="2">
  226.                                     <input type="text" name="T12" size="20"></font></td>
  227.                                     <td valign="top" height="37" width="170">
  228.                                     <font size="2"><b>Fax:</b><br>
  229.                                     <input type="text" name="T13" size="20"></font></td>
  230.                                 </tr>
  231.                                 <tr>
  232.                                     <td valign="top" height="37" width="331" colspan="2">
  233.                                     <font size="2"><b>Email:</b><br>
  234.                                     <input type="text" name="T14" size="38"></font></td>
  235.                                 </tr>
  236.                                 <tr>
  237.                                     <td valign="top" height="35" width="331" colspan="2">
  238.                                     <b><font size="2">Room:<br>
  239.                                     <input type="checkbox" name="C10" value="ON">King&nbsp;
  240.                                     <input type="checkbox" name="C11" value="ON">Double&nbsp;
  241.                                     <input type="checkbox" name="C12" value="ON">Smoking&nbsp;
  242.                                     <input type="checkbox" name="C13" value="ON">Non-Smoking</font></b></td>
  243.                                 </tr>
  244.                                 <tr>
  245.                                     <td valign="top" height="50" width="331" colspan="2">
  246.                                     <b><font size="2"><br>
  247.                                     T-Shirt:<br>
  248.                                     <input type="checkbox" name="C14" value="ON">XXL&nbsp;
  249.                                     <input type="checkbox" name="C15" value="ON">XL&nbsp;
  250.                                     <input type="checkbox" name="C16" value="ON">Large&nbsp;
  251.                                     <input type="checkbox" name="C17" value="ON">Medium&nbsp;
  252.                                     <input type="checkbox" name="C18" value="ON">Small</font></b></td>
  253.                                 </tr>
  254.                             </table>
  255.                             </td>
  256.                         </tr>
  257.                         <tr>
  258.                             <td style="border-style: solid; border-width: 1px" valign="top" width="344">
  259.                             <table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
  260.                                 <tr>
  261.                                     <td valign="top" height="20" width="331" colspan="2">
  262.                                     <p align="center"><b><font size="4">Player 
  263.                                     Three</font></b></td>
  264.                                 </tr>
  265.                                 <tr>
  266.                                     <td valign="top" height="37" width="331" colspan="2">
  267.                                     <font size="2"><b>Golfers Name:</b><br>
  268.                                     <input type="text" name="T15" size="25"></font></td>
  269.                                 </tr>
  270.                                 <tr>
  271.                                     <td valign="top" height="37" width="331" colspan="2">
  272.                                     <font size="2"><b>Guests Name:</b><br>
  273.                                     <input type="text" name="T16" size="25"></font></td>
  274.                                 </tr>
  275.                                 <tr>
  276.                                     <td valign="top" height="37" width="331" colspan="2">
  277.                                     <font size="2"><b>Company:</b><br>
  278.                                     <input type="text" name="T17" size="30"></font></td>
  279.                                 </tr>
  280.                                 <tr>
  281.                                     <td valign="top" height="37" width="331" colspan="2">
  282.                                     <font size="2"><b>Home Address:</b><br>
  283.                                     <input type="text" name="T18" size="48"></font></td>
  284.                                 </tr>
  285.                                 <tr>
  286.                                     <td valign="top" height="37" width="173"><b>
  287.                                     <font size="2">Phone:<br>
  288.                                     </font></b><font size="2">
  289.                                     <input type="text" name="T19" size="20"></font></td>
  290.                                     <td valign="top" height="37" width="171">
  291.                                     <font size="2"><b>Fax:</b><br>
  292.                                     <input type="text" name="T20" size="20"></font></td>
  293.                                 </tr>
  294.                                 <tr>
  295.                                     <td valign="top" height="37" width="331" colspan="2">
  296.                                     <font size="2"><b>Email:</b><br>
  297.                                     <input type="text" name="T21" size="38"></font></td>
  298.                                 </tr>
  299.                                 <tr>
  300.                                     <td valign="top" height="35" width="331" colspan="2">
  301.                                     <b><font size="2">Room:<br>
  302.                                     <input type="checkbox" name="C19" value="ON">King&nbsp;
  303.                                     <input type="checkbox" name="C20" value="ON">Double&nbsp;
  304.                                     <input type="checkbox" name="C21" value="ON">Smoking&nbsp;
  305.                                     <input type="checkbox" name="C22" value="ON">Non-Smoking</font></b></td>
  306.                                 </tr>
  307.                                 <tr>
  308.                                     <td valign="top" height="50" width="331" colspan="2">
  309.                                     <b><font size="2"><br>
  310.                                     T-Shirt:<br>
  311.                                     <input type="checkbox" name="C23" value="ON">XXL&nbsp;
  312.                                     <input type="checkbox" name="C24" value="ON">XL&nbsp;
  313.                                     <input type="checkbox" name="C25" value="ON">Large&nbsp;
  314.                                     <input type="checkbox" name="C26" value="ON">Medium&nbsp;
  315.                                     <input type="checkbox" name="C27" value="ON">Small</font></b></td>
  316.                                 </tr>
  317.                             </table>
  318.                             </td>
  319.                             <td style="border-style: solid; border-width: 1px" valign="top">
  320.                             <table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
  321.                                 <tr>
  322.                                     <td valign="top" height="20" width="331" colspan="2">
  323.                                     <p align="center"><b><font size="4">Player 
  324.                                     Four</font></b></td>
  325.                                 </tr>
  326.                                 <tr>
  327.                                     <td valign="top" height="37" width="331" colspan="2">
  328.                                     <font size="2"><b>Golfers Name:</b><br>
  329.                                     <input type="text" name="T22" size="25"></font></td>
  330.                                 </tr>
  331.                                 <tr>
  332.                                     <td valign="top" height="37" width="331" colspan="2">
  333.                                     <font size="2"><b>Guests Name:</b><br>
  334.                                     <input type="text" name="T23" size="25"></font></td>
  335.                                 </tr>
  336.                                 <tr>
  337.                                     <td valign="top" height="37" width="331" colspan="2">
  338.                                     <font size="2"><b>Company:</b><br>
  339.                                     <input type="text" name="T24" size="30"></font></td>
  340.                                 </tr>
  341.                                 <tr>
  342.                                     <td valign="top" height="37" width="331" colspan="2">
  343.                                     <font size="2"><b>Home Address:</b><br>
  344.                                     <input type="text" name="T25" size="48"></font></td>
  345.                                 </tr>
  346.                                 <tr>
  347.                                     <td valign="top" height="37" width="174"><b>
  348.                                     <font size="2">Phone:<br>
  349.                                     </font></b><font size="2">
  350.                                     <input type="text" name="T26" size="20"></font></td>
  351.                                     <td valign="top" height="37" width="170">
  352.                                     <font size="2"><b>Fax:</b><br>
  353.                                     <input type="text" name="T27" size="20"></font></td>
  354.                                 </tr>
  355.                                 <tr>
  356.                                     <td valign="top" height="37" width="331" colspan="2">
  357.                                     <font size="2"><b>Email:</b><br>
  358.                                     <input type="text" name="T28" size="38"></font></td>
  359.                                 </tr>
  360.                                 <tr>
  361.                                     <td valign="top" height="35" width="331" colspan="2">
  362.                                     <b><font size="2">Room:<br>
  363.                                     <input type="checkbox" name="C28" value="ON">King&nbsp;
  364.                                     <input type="checkbox" name="C29" value="ON">Double&nbsp;
  365.                                     <input type="checkbox" name="C30" value="ON">Smoking&nbsp;
  366.                                     <input type="checkbox" name="C31" value="ON">Non-Smoking</font></b></td>
  367.                                 </tr>
  368.                                 <tr>
  369.                                     <td valign="top" height="50" width="331" colspan="2">
  370.                                     <b><font size="2"><br>
  371.                                     T-Shirt:<br>
  372.                                     <input type="checkbox" name="C32" value="ON">XXL&nbsp;
  373.                                     <input type="checkbox" name="C33" value="ON">XL&nbsp;
  374.                                     <input type="checkbox" name="C34" value="ON">Large&nbsp;
  375.                                     <input type="checkbox" name="C35" value="ON">Medium&nbsp;
  376.                                     <input type="checkbox" name="C36" value="ON">Small</font></b></td>
  377.                                 </tr>
  378.                             </table>
  379.                             </td>
  380.                         </tr>
  381.                     </table>
  382.                     <p><input type="submit" value="Submit Form" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  383.                     <input type="reset" value="Reset Form Fields" name="B2"></p>
  384.                 <input type="hidden" name="_submit" value="1" /></form>
  385.             </div>
  386.             </td>
  387.         </tr>
  388.     </table>
  389. </div>
  390. <p>&nbsp;</p>
  391.  
  392. </body>
  393.  
  394. </html>
  395. <?php
  396. ////////////////////////////////////////////////////////////////////////////////
  397. /**
  398.  * Color the description of a field to red when an error has been found.
  399.  */
  400. function is_err($field) {
  401.   global $ertags;
  402.   if (in_array($field, $ertags))
  403.      echo " style='color:red;' ";
  404.   else 
  405.      echo "";
  406. }
  407. ?>
Feb 1 '10 #8
zorgi
431 Expert 256MB
Correct me if I'm wrong but you posted the same thing again!?
Feb 1 '10 #9
Chrisjc
375 256MB
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?
Feb 1 '10 #10
Chrisjc
375 256MB
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.
Feb 1 '10 #11
Chrisjc
375 256MB
ahh crap I think I see why now, grr I hate this... not very good at this at all... one sec
Feb 1 '10 #12
Chrisjc
375 256MB
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.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4. <meta http-equiv="Content-Language" content="en-us">
  5. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  6. <title>Players / Foursome</title>
  7. </head>
  8.  
  9. <body>
  10.  
  11. <div align="center">
  12.     <table border="0" width="44%" height="646">
  13.         <tr>
  14.             <td valign="top">
  15.             <table border="0" width="100%" style="border-bottom-width: 0px">
  16.                 <tr>
  17.                     <td valign="top" style="border-bottom-style: none; border-bottom-width: medium">&nbsp;<b><font size="5">Players 
  18.                     / Foursome</font></b></td>
  19.                 </tr>
  20.             </table>
  21.             <?php
  22. $errors = array();                        // array to hold error messages
  23. $ertags = array();                        // array to hold names of erroneous fields
  24. // ===========================================================================
  25. // When the form is submitted:
  26. // a. all fields: 'sanitize' by removing code tags
  27. // b. mandatory fields: check for validity and content (some)
  28. // ===========================================================================
  29. if (isset($_POST['_submit'])) {
  30.   // ----------------------------------------------------
  31.   // remove harmful code tags from all $_POST variables
  32.   // ----------------------------------------------------
  33.   foreach ($_POST as $key => $val) {
  34.     $_POST[$key] = trim(strip_tags($val));
  35.   }
  36.   // ----------------------------------------------------
  37.   // Verify existence and content of mandatory fields:
  38.   //
  39.   // Golfers Name               Golfers Name
  40.   // Guests Name                 Guests Name
  41.   // Company                       Company
  42.   // Home Address                Home Address
  43.   // Phone                          Phone
  44.   // Fax                          Fax
  45.   // Email                      E-mail           (valid e-mail address)
  46.   // Room                        Room
  47.   // Smoking                    Smoking
  48.   // Shirt                        Shirt
  49.   // ----------------------------------------------------
  50.   //
  51.   // Golfers Name
  52.   if (!isset($_POST['P1GN']) OR $_POST['P1GN'] == '') {
  53.      $errors[] = "Golfers Name invalid";
  54.      $ertags[] = 'P1GN';
  55.   }
  56.   // Guests Name
  57.   if (!isset($_POST['P1GUN']) OR $_POST['P1GUN'] == '') {
  58.      $errors[] = "Guests Name invalid";
  59.      $ertags[] = 'P1GUN';
  60.   }
  61.   // Company
  62.   if (!isset($_POST['P1C']) OR $_POST['P1C'] == '') {
  63.      $errors[] = "Company invalid";
  64.      $ertags[] = 'P1C';
  65.   }
  66.   // Home Address
  67.   if (!isset($_POST['P1HA']) OR $_POST['P1HA'] == '') {
  68.      $errors[] = "Home Address invalid";
  69.      $ertags[] = 'P1HA';
  70.   }
  71.     // Phone
  72.   if (!isset($_POST['P1P']) OR $_POST['P1P'] == '') {
  73.      $errors[] = "Phone invalid";
  74.      $ertags[] = 'P1P';
  75.   }
  76.   // Fax
  77.   if (!isset($_POST['P1F']) OR $_POST['P1F'] == '') {
  78.      $errors[] = "Fax invalid";
  79.      $ertags[] = 'P1F';
  80.   }
  81.   // Email (check also if valid e-mail address)
  82.   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'])) {
  83.      $errors[] = "E-mail address invalid";
  84.      $ertags[] = 'P1EM';
  85.      }
  86.   // Room
  87.   if (!isset($_POST['P1R']) OR $_POST['P1R'] == '') {
  88.      $errors[] = "Room invalid";
  89.      $ertags[] = 'P1R';
  90.   }
  91.   // Shirt
  92.   if (!isset($_POST['P1SM']) OR $_POST['P1SM'] == '') {
  93.      $errors[] = "Shirt invalid";
  94.      $ertags[] = 'P1SM';
  95.   }
  96.   // -------------------------------------------------------
  97.   // ERRORS FOUND: print out and re-display form
  98.   // -------------------------------------------------------
  99.   if ($errors) {
  100.      echo '<div style="margin-left:250px;font-size:12px;font-family:Tahoma;color:red;">';
  101.      echo '<u><b>The following errors were encountered (see highlighted fields):</b></u><ul><li>';
  102.      echo implode('</li><li>',$errors);
  103.      echo '</li></ul></div>';
  104.   }
  105.   else {
  106.      // -------------------------------------------------------
  107.      // NO ERRORS FOUND: continue and construct e-mail message
  108.      // -------------------------------------------------------
  109.      // echo '<pre>'; print_r($_POST); echo '<br>'; 
  110.      include("convertPost.php");
  111.      exit;
  112.   }
  113.  
  114. } // END if isset _submitted
  115. // ==================================================================================
  116. // (Re) Display the form
  117. // ==================================================================================
  118. ?>
  119.             <hr size="1" color="#000000">
  120.             <div align="center">
  121.                 <form name="myForm" action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
  122.                     <table border="0" cellspacing="10" cellpadding="3">
  123.                         <tr>
  124.                             <td style="border-style: solid; border-width: 1px" valign="top" width="344">
  125.                             <table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
  126.                                 <tr>
  127.                                     <td valign="top" height="20" width="331" colspan="2">
  128.                                     <p align="center"><b><font size="4">Player 
  129.                                     One</font></b></td>
  130.                                 </tr>
  131.                                 <tr>
  132.                                     <td valign="top" height="37" width="331" colspan="2">
  133.                                     <font size="2"><b>Golfers Name:</b><br>
  134.                                     <input type="text" name="P1GN" size="25" tabindex="1" value="<?php echo (isset($_POST['P1GN'])) ? $_POST['P1GN'] : ""; ?>"></font></td>
  135.                                 </tr>
  136.                                 <tr>
  137.                                     <td valign="top" height="37" width="331" colspan="2">
  138.                                     <font size="2"><b>Guests Name:</b><br>
  139.                                     <input type="text" name="P1GUN" size="25" tabindex="2" value="<?php echo (isset($_POST['P1GUN'])) ? $_POST['P1GUN'] : ""; ?>"></font></td>
  140.                                 </tr>
  141.                                 <tr>
  142.                                     <td valign="top" height="37" width="331" colspan="2">
  143.                                     <font size="2"><b>Company:</b><br>
  144.                                     <input type="text" name="P1C" size="30" tabindex="3" value="<?php echo (isset($_POST['P1GUN'])) ? $_POST['P1GUN'] : ""; ?>"></font></td>
  145.                                 </tr>
  146.                                 <tr>
  147.                                     <td valign="top" height="37" width="331" colspan="2">
  148.                                     <font size="2"><b>Home Address:</b><br>
  149.                                     <input type="text" name="P1HA" size="48" tabindex="4" value="<?php echo (isset($_POST['P1HA'])) ? $_POST['P1HA'] : ""; ?>"></font></td>
  150.                                 </tr>
  151.                                 <tr>
  152.                                     <td valign="top" height="37" width="175"><b>
  153.                                     <font size="2">Phone:<br>
  154.                                     </font></b><font size="2">
  155.                                     <input type="text" name="P1P" size="20" tabindex="5" value="<?php echo (isset($_POST['P1P'])) ? $_POST['P1P'] : ""; ?>"></font></td>
  156.                                     <td valign="top" height="37" width="169">
  157.                                     <font size="2"><b>Fax:</b><br>
  158.                                     <input type="text" name="P1F" size="20" tabindex="6" value="<?php echo (isset($_POST['P1F'])) ? $_POST['P1F'] : ""; ?>"></font></td>
  159.                                 </tr>
  160.                                 <tr>
  161.                                     <td valign="top" height="37" width="331" colspan="2">
  162.                                     <font size="2"><b>Email:</b><br>
  163.                                     <input type="text" name="P1EM" size="38" tabindex="7" value="<?php echo (isset($_POST['P1EMl'])) ? $_POST['P1EMl'] : ""; ?>"></font></td>
  164.                                 </tr>
  165.                                 <tr>
  166.                                     <td valign="top" height="35" width="331" colspan="2">
  167.                                     <b><font size="2">Room:<br>
  168.                                     <select size="1" name="P1R">
  169.                                     <option selected>Select Bed Size</option>
  170.                                     <option>King</option>
  171.                                     <option>Double</option>
  172.                                     <?php echo (isset($_POST['P1R'])) ? $_POST['P1R'] : ""; ?></select>&nbsp;&nbsp;&nbsp;&nbsp;
  173.                                     <select size="1" name="P1SM">
  174.                                     <option selected>Smoking or Non-Smoking
  175.                                     </option>
  176.                                     <option>Smoking</option>
  177.                                     <option>Non-Smoking</option>
  178.                                     <?php echo (isset($_POST['P1SM'])) ? $_POST['P1SM'] : ""; ?></select></font></b></td>
  179.                                 </tr>
  180.                                 <tr>
  181.                                     <td valign="top" height="50" width="331" colspan="2">
  182.                                     <b><font size="2"><br>
  183.                                     T-Shirt:<br>
  184.                                     <select size="1" name="P1TS">
  185.                                     <option selected>Select Your Size</option>
  186.                                     <option>XXL</option>
  187.                                     <option>XL</option>
  188.                                     <option>Large</option>
  189.                                     <option>Medium</option>
  190.                                     <option>Small</option>
  191.                                     <?php echo (isset($_POST['P1TS'])) ? $_POST['P1TS'] : ""; ?></select></font></b></td>
  192.                                 </tr>
  193.                             </table>
  194.                             </td>
  195.                             <td style="border-style: solid; border-width: 1px" valign="top">
  196.                             <table border="0" width="331" cellspacing="0" cellpadding="0" height="326">
  197.                                 <tr>
  198.                                     <td valign="top" height="19" width="331" colspan="2">
  199.                                     <p align="center"><b><font size="4">Player 
  200.                                     Two</font></b></td>
  201.                                 </tr>
  202.                                 <tr>
  203.                                     <td valign="top" height="37" width="331" colspan="2">
  204.                                     <font size="2"><b>Golfers Name:</b><br>
  205.                                     <input type="text" name="T8" size="25"></font></td>
  206.                                 </tr>
  207.                                 <tr>
  208.                                     <td valign="top" height="37" width="331" colspan="2">
  209.                                     <font size="2"><b>Guests Name:</b><br>
  210.                                     <input type="text" name="T9" size="25"></font></td>
  211.                                 </tr>
  212.                                 <tr>
  213.                                     <td valign="top" height="37" width="331" colspan="2">
  214.                                     <font size="2"><b>Company:</b><br>
  215.                                     <input type="text" name="T10" size="30"></font></td>
  216.                                 </tr>
  217.                                 <tr>
  218.                                     <td valign="top" height="37" width="331" colspan="2">
  219.                                     <font size="2"><b>Home Address:</b><br>
  220.                                     <input type="text" name="T11" size="48"></font></td>
  221.                                 </tr>
  222.                                 <tr>
  223.                                     <td valign="top" height="37" width="174"><b>
  224.                                     <font size="2">Phone:<br>
  225.                                     </font></b><font size="2">
  226.                                     <input type="text" name="T12" size="20"></font></td>
  227.                                     <td valign="top" height="37" width="170">
  228.                                     <font size="2"><b>Fax:</b><br>
  229.                                     <input type="text" name="T13" size="20"></font></td>
  230.                                 </tr>
  231.                                 <tr>
  232.                                     <td valign="top" height="37" width="331" colspan="2">
  233.                                     <font size="2"><b>Email:</b><br>
  234.                                     <input type="text" name="T14" size="38"></font></td>
  235.                                 </tr>
  236.                                 <tr>
  237.                                     <td valign="top" height="35" width="331" colspan="2">
  238.                                     <b><font size="2">Room:<br>
  239.                                     <input type="checkbox" name="C10" value="ON">King&nbsp;
  240.                                     <input type="checkbox" name="C11" value="ON">Double&nbsp;
  241.                                     <input type="checkbox" name="C12" value="ON">Smoking&nbsp;
  242.                                     <input type="checkbox" name="C13" value="ON">Non-Smoking</font></b></td>
  243.                                 </tr>
  244.                                 <tr>
  245.                                     <td valign="top" height="50" width="331" colspan="2">
  246.                                     <b><font size="2"><br>
  247.                                     T-Shirt:<br>
  248.                                     <input type="checkbox" name="C14" value="ON">XXL&nbsp;
  249.                                     <input type="checkbox" name="C15" value="ON">XL&nbsp;
  250.                                     <input type="checkbox" name="C16" value="ON">Large&nbsp;
  251.                                     <input type="checkbox" name="C17" value="ON">Medium&nbsp;
  252.                                     <input type="checkbox" name="C18" value="ON">Small</font></b></td>
  253.                                 </tr>
  254.                             </table>
  255.                             </td>
  256.                         </tr>
  257.                         <tr>
  258.                             <td style="border-style: solid; border-width: 1px" valign="top" width="344">
  259.                             <table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
  260.                                 <tr>
  261.                                     <td valign="top" height="20" width="331" colspan="2">
  262.                                     <p align="center"><b><font size="4">Player 
  263.                                     Three</font></b></td>
  264.                                 </tr>
  265.                                 <tr>
  266.                                     <td valign="top" height="37" width="331" colspan="2">
  267.                                     <font size="2"><b>Golfers Name:</b><br>
  268.                                     <input type="text" name="T15" size="25"></font></td>
  269.                                 </tr>
  270.                                 <tr>
  271.                                     <td valign="top" height="37" width="331" colspan="2">
  272.                                     <font size="2"><b>Guests Name:</b><br>
  273.                                     <input type="text" name="T16" size="25"></font></td>
  274.                                 </tr>
  275.                                 <tr>
  276.                                     <td valign="top" height="37" width="331" colspan="2">
  277.                                     <font size="2"><b>Company:</b><br>
  278.                                     <input type="text" name="T17" size="30"></font></td>
  279.                                 </tr>
  280.                                 <tr>
  281.                                     <td valign="top" height="37" width="331" colspan="2">
  282.                                     <font size="2"><b>Home Address:</b><br>
  283.                                     <input type="text" name="T18" size="48"></font></td>
  284.                                 </tr>
  285.                                 <tr>
  286.                                     <td valign="top" height="37" width="173"><b>
  287.                                     <font size="2">Phone:<br>
  288.                                     </font></b><font size="2">
  289.                                     <input type="text" name="T19" size="20"></font></td>
  290.                                     <td valign="top" height="37" width="171">
  291.                                     <font size="2"><b>Fax:</b><br>
  292.                                     <input type="text" name="T20" size="20"></font></td>
  293.                                 </tr>
  294.                                 <tr>
  295.                                     <td valign="top" height="37" width="331" colspan="2">
  296.                                     <font size="2"><b>Email:</b><br>
  297.                                     <input type="text" name="T21" size="38"></font></td>
  298.                                 </tr>
  299.                                 <tr>
  300.                                     <td valign="top" height="35" width="331" colspan="2">
  301.                                     <b><font size="2">Room:<br>
  302.                                     <input type="checkbox" name="C19" value="ON">King&nbsp;
  303.                                     <input type="checkbox" name="C20" value="ON">Double&nbsp;
  304.                                     <input type="checkbox" name="C21" value="ON">Smoking&nbsp;
  305.                                     <input type="checkbox" name="C22" value="ON">Non-Smoking</font></b></td>
  306.                                 </tr>
  307.                                 <tr>
  308.                                     <td valign="top" height="50" width="331" colspan="2">
  309.                                     <b><font size="2"><br>
  310.                                     T-Shirt:<br>
  311.                                     <input type="checkbox" name="C23" value="ON">XXL&nbsp;
  312.                                     <input type="checkbox" name="C24" value="ON">XL&nbsp;
  313.                                     <input type="checkbox" name="C25" value="ON">Large&nbsp;
  314.                                     <input type="checkbox" name="C26" value="ON">Medium&nbsp;
  315.                                     <input type="checkbox" name="C27" value="ON">Small</font></b></td>
  316.                                 </tr>
  317.                             </table>
  318.                             </td>
  319.                             <td style="border-style: solid; border-width: 1px" valign="top">
  320.                             <table border="0" width="331" cellspacing="0" cellpadding="0" height="327">
  321.                                 <tr>
  322.                                     <td valign="top" height="20" width="331" colspan="2">
  323.                                     <p align="center"><b><font size="4">Player 
  324.                                     Four</font></b></td>
  325.                                 </tr>
  326.                                 <tr>
  327.                                     <td valign="top" height="37" width="331" colspan="2">
  328.                                     <font size="2"><b>Golfers Name:</b><br>
  329.                                     <input type="text" name="T22" size="25"></font></td>
  330.                                 </tr>
  331.                                 <tr>
  332.                                     <td valign="top" height="37" width="331" colspan="2">
  333.                                     <font size="2"><b>Guests Name:</b><br>
  334.                                     <input type="text" name="T23" size="25"></font></td>
  335.                                 </tr>
  336.                                 <tr>
  337.                                     <td valign="top" height="37" width="331" colspan="2">
  338.                                     <font size="2"><b>Company:</b><br>
  339.                                     <input type="text" name="T24" size="30"></font></td>
  340.                                 </tr>
  341.                                 <tr>
  342.                                     <td valign="top" height="37" width="331" colspan="2">
  343.                                     <font size="2"><b>Home Address:</b><br>
  344.                                     <input type="text" name="T25" size="48"></font></td>
  345.                                 </tr>
  346.                                 <tr>
  347.                                     <td valign="top" height="37" width="174"><b>
  348.                                     <font size="2">Phone:<br>
  349.                                     </font></b><font size="2">
  350.                                     <input type="text" name="T26" size="20"></font></td>
  351.                                     <td valign="top" height="37" width="170">
  352.                                     <font size="2"><b>Fax:</b><br>
  353.                                     <input type="text" name="T27" size="20"></font></td>
  354.                                 </tr>
  355.                                 <tr>
  356.                                     <td valign="top" height="37" width="331" colspan="2">
  357.                                     <font size="2"><b>Email:</b><br>
  358.                                     <input type="text" name="T28" size="38"></font></td>
  359.                                 </tr>
  360.                                 <tr>
  361.                                     <td valign="top" height="35" width="331" colspan="2">
  362.                                     <b><font size="2">Room:<br>
  363.                                     <input type="checkbox" name="C28" value="ON">King&nbsp;
  364.                                     <input type="checkbox" name="C29" value="ON">Double&nbsp;
  365.                                     <input type="checkbox" name="C30" value="ON">Smoking&nbsp;
  366.                                     <input type="checkbox" name="C31" value="ON">Non-Smoking</font></b></td>
  367.                                 </tr>
  368.                                 <tr>
  369.                                     <td valign="top" height="50" width="331" colspan="2">
  370.                                     <b><font size="2"><br>
  371.                                     T-Shirt:<br>
  372.                                     <input type="checkbox" name="C32" value="ON">XXL&nbsp;
  373.                                     <input type="checkbox" name="C33" value="ON">XL&nbsp;
  374.                                     <input type="checkbox" name="C34" value="ON">Large&nbsp;
  375.                                     <input type="checkbox" name="C35" value="ON">Medium&nbsp;
  376.                                     <input type="checkbox" name="C36" value="ON">Small</font></b></td>
  377.                                 </tr>
  378.                             </table>
  379.                             </td>
  380.                         </tr>
  381.                     </table>
  382.                     <p><input type="submit" value="Submit Form" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  383.                     <input type="reset" value="Reset Form Fields" name="B2"></p>
  384.                 <input type="hidden" name="_submit" value="1" /></form>
  385.             </div>
  386.             </td>
  387.         </tr>
  388.     </table>
  389. </div>
  390. <p>&nbsp;</p>
  391.  
  392. </body>
  393.  
  394. </html>
  395. <?php
  396. ////////////////////////////////////////////////////////////////////////////////
  397. /**
  398.  * Color the description of a field to red when an error has been found.
  399.  */
  400. function is_err($field) {
  401.   global $ertags;
  402.   if (in_array($field, $ertags))
  403.      echo " style='color:red;' ";
  404.   else 
  405.      echo "";
  406. }
  407. ?>
How would I correct the statments to check if they selected an option

Expand|Select|Wrap|Line Numbers
  1.   // Room
  2.   if (!isset($_POST['P1R']) OR $_POST['P1R'] == '') {
  3.      $errors[] = "Room invalid";
  4.      $ertags[] = 'P1R';
  5.   }
  6.   // Shirt
  7.   if (!isset($_POST['P1SM']) OR $_POST['P1SM'] == '') {
  8.      $errors[] = "Shirt invalid";
  9.      $ertags[] = 'P1SM';
Feb 1 '10 #13
zorgi
431 Expert 256MB
This is your code:

Expand|Select|Wrap|Line Numbers
  1. <select size="1" name="P1R">
  2. <option selected>Select Bed Size</option>
  3. <option>King</option>
  4. <option>Double</option>
  5. <?php echo (isset($_POST['P1R'])) ? $_POST['P1R'] : ""; ?></select>
  6.  
Your options don't have values?! You should give them values like this:

Expand|Select|Wrap|Line Numbers
  1. <select size="1" name="P1R">
  2. <option value="">Select Bed Size</option>
  3. <option value="king">King</option>
  4. <option value="double">Double</option>
  5. </select>
  6.  
Only now they have some use. Now you can add php too:

Expand|Select|Wrap|Line Numbers
  1. <select size="1" name="P1R">
  2. <option value="">Select Bed Size</option>
  3. <option value="king" <?php echo ($_POST['P1R'] == "king")?("selected"):(""); ?>>King</option>
  4. <option value="double" <?php echo ($_POST['P1R'] == "double")?("selected"):(""); ?>>Double</option>
  5. </select>
  6.  
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.
Feb 1 '10 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Tyler Style | last post by:
Hullo - looking for a little advice here. I have a form on a page in one domain submitting to a cgi in another domain. Weirdly, on some Windows XP systems, a form on the page fails to submit/post...
2
by: google | last post by:
Hello everyone, I am having an issue using the "Multi Select" option in a list box in MS Access 2003. I am making a form that users can fill out to add an issue to the database. Each issue can...
22
by: Br | last post by:
First issue: When using ADPs you no longer have the ability to issue a me.refresh to save the current record on a form (the me.refresh does a requery in an ADP). We usually do this before...
5
by: ortaias | last post by:
I have a form which calls up a second form for purposes of data entry. When closing the data entry form and returning to the main form, things don't work as expected. When I return to the main...
4
by: crystal | last post by:
I've checked the threads but haven't been able to come up with a solution to my issue. Help...... I have a simple form based on a table. Within the form is a subform that is also, through a Q,...
11
by: Zytan | last post by:
I have created a new form from the main form. When I close the main form with the 'x' close button, its Form.FormClosed event is run, but not the dialog's. Is this normal? It is ok /...
26
by: Jerim79 | last post by:
I need to create a form that takes a number that the user enters, and duplicates a question the number of times the user entered. For instance, if the customer enters 5 on the first page, when...
22
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is changing. But, the form may not exist (it is...
1
by: peck2000 | last post by:
Related to my earleir post ... this is the same project to re-purpose the Classifieds application in BEGINNING ASP 3.0 (Wrox) to a comicbook database ... This is a brainteaser that should have...
5
by: programmerboy | last post by:
I never had this kind of issue before and it is completely surprising. I have a usercontrol where I need 2 forms to make 1 form. When I have only 1 form it submits the page to itself. I have spent...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.