471,616 Members | 1,849 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

php form not working with IE

Have a form that works with FF, Chrome but not working with any version of IE.

http://www.tetonvillagesports.net/reso.htm

the contact.php script is as follows:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. /* Set e-mail recipient */
  3. $myemail  = "rentals@example.com";
  4.  
  5.  
  6. /* Check all form inputs using check_input function */
  7. $group = check_input($_POST['group']);
  8. $yourname = check_input($_POST['yourname']);
  9. $address = check_input($_POST['address']);
  10. $city = check_input($_POST['city']);
  11. $state = check_input($_POST['state']);
  12. $zip = check_input($_POST['zip']);
  13. $phone = check_input($_POST['phone']);
  14. $email = check_input($_POST['email'], "Enter your email address");
  15. $arrival_date = check_input($_POST['arrival_date']);
  16. $departure_date = check_input($_POST['departure_date']);
  17. $local_lodging = check_input($_POST['local_lodging']);
  18. $num_days = check_input($_POST['num_days']);
  19. $name1 = check_input($_POST['name1']);
  20. $age1 = check_input($_POST['age1']);
  21. $height1 = check_input($_POST['height1']);
  22. $weight1 = check_input($_POST['weight1']);
  23. $sport_equip1 = check_input($_POST['1sport_equi1p']);
  24. $sport_ski_size1 = check_input($_POST['sport_ski_size1']);
  25. $demo_equip1 = check_input($_POST['demo_equip1']);
  26. $demo_ski_model1 = check_input($_POST['demo_ski_model1']);
  27. $demo_ski_size1 = check_input($_POST['demo_ski_size1']);
  28. $shoe_size1 = check_input($_POST['shoe_size1']);
  29. $board_equip1 = check_input($_POST['board_equip1']);
  30. $board_size1 = check_input($_POST['board_size1']);
  31. $jr_equip1 = check_input($_POST['jr_equip1']);
  32. $jr_ski_size1 = check_input($_POST['jr_ski_size1']);
  33. $skier_type1 = check_input($_POST['skier_type1']);
  34. $comment1 = check_input($_POST['comment1']);
  35. $name2 = check_input($_POST['name2']);
  36. $age2 = check_input($_POST['age2']);
  37. $height2 = check_input($_POST['height2']);
  38. $weight2 = check_input($_POST['weight2']);
  39. $sport_equip2 = check_input($_POST['sport_equip2']);
  40. $sport_ski_size2 = check_input($_POST['sport_ski_size2']);
  41. $demo_equip2 = check_input($_POST['demo_equip2']);
  42. $demo_ski_model2 = check_input($_POST['demo_ski_model2']);
  43. $demo_ski_size2 = check_input($_POST['demo_ski_size2']);
  44. $shoe_size2 = check_input($_POST['shoe_size2']);
  45. $board_equip2 = check_input($_POST['board_equip2']);
  46. $board_size2 = check_input($_POST['board_size2']);
  47. $jr_equip2 = check_input($_POST['jr_equip2']);
  48. $jr_ski_size2 = check_input($_POST['jr_ski_size2']);
  49. $skier_type2 = check_input($_POST['skier_type2']);
  50. $comment2 = check_input($_POST['comment2']);
  51. $name3 = check_input($_POST['name3']);
  52. $age3 = check_input($_POST['age3']);
  53. $height3 = check_input($_POST['height3']);
  54. $weight3 = check_input($_POST['weight3']);
  55. $sport_equip3 = check_input($_POST['sport_equip3']);
  56. $sport_ski_size3 = check_input($_POST['sport_ski_size3']);
  57. $demo_equip3 = check_input($_POST['demo_equip3']);
  58. $demo_ski_model3 = check_input($_POST['demo_ski_model3']);
  59. $demo_ski_size3 = check_input($_POST['demo_ski_size3']);
  60. $shoe_size3 = check_input($_POST['shoe_size3']);
  61. $board_equip3 = check_input($_POST['board_equip3']);
  62. $board_size3 = check_input($_POST['board_size3']);
  63. $jr_equip3 = check_input($_POST['jr_equip3']);
  64. $jr_ski_size3 = check_input($_POST['jr_ski_size3']);
  65. $skier_type3 = check_input($_POST['skier_type3']);
  66. $comment3 = check_input($_POST['comment3']);
  67. $name4 = check_input($_POST['name4']);
  68. $age4 = check_input($_POST['age4']);
  69. $height4 = check_input($_POST['height4']);
  70. $weight4 = check_input($_POST['weight4']);
  71. $sport_equip4 = check_input($_POST['sport_equip4']);
  72. $sport_ski_size4 = check_input($_POST['sport_ski_size4']);
  73. $demo_equip4 = check_input($_POST['demo_equip4']);
  74. $demo_ski_model4 = check_input($_POST['demo_ski_model4']);
  75. $demo_ski_size4 = check_input($_POST['demo_ski_size4']);
  76. $shoe_size4 = check_input($_POST['shoe_size4']);
  77. $board_equip4 = check_input($_POST['board_equip4']);
  78. $board_size4 = check_input($_POST['board_size4']);
  79. $jr_equip4 = check_input($_POST['jr_equip4']);
  80. $jr_ski_size4 = check_input($_POST['jr_ski_size4']);
  81. $skier_type4 = check_input($_POST['skier_type4']);
  82. $comment4 = check_input($_POST['comment4']);
  83.  
  84.  
  85. /* If e-mail is not valid show error message */
  86. if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
  87. {
  88.     show_error("E-mail address not valid");
  89. }
  90.  
  91.  
  92. /* Let's prepare the message for the e-mail */
  93. $message = "What is up your rentalness!
  94.  
  95. Everybody wants some, this person wants some too:
  96. _______________________________________
  97. Group Name: $group
  98.  
  99. Name: $yourname
  100. Contact Address: $address
  101. City: $city
  102. State: $state
  103. Zip Code: $zip
  104. Daytime Phone:  $phone
  105. Contact E-mail: $email
  106. Arrival Date: $arrival_date
  107. Departure Date: $departure_date
  108. Local Accomodations: $local_lodging
  109. Number of days skiing: $num_days
  110. __________________________________________
  111. RENTER #1
  112.    Name: $name1
  113.    Birth Date:  $age1
  114.    Height (ft/in): $height1
  115.    Weight (lbs): $weight1
  116. SPORT EQUIPMENT
  117.    Package Type: $sport_equip1
  118.    Sport Ski Size: $sport_ski_size1
  119.    Shoe size: $shoe_size1
  120. DEMO SKIS
  121.    Package Type: $demo_equip1
  122.    Demo ski model: $demo_ski_model1
  123.    Demo Ski size: $demo_ski_size1
  124.    Shoe size: $shoe_size1
  125. SNOWBOARD
  126.    Package Type: $board_equip1
  127.    Board size: $board_size1
  128.    Shoe size: $shoe_size1
  129. KID'S EQUIPMENT (12 and under)
  130.    Junior Pakage: $jr_equip1
  131.    Ski Length: $jr_ski_size1
  132.    Shoe size: $shoe_size1
  133. Skier Type: $skier_type1
  134. Comments: $comment1
  135. ___________________________________
  136. RENTER #2
  137.    Name: $name2
  138.    Birth Date:  $age2
  139.    Height (ft/in): $height2
  140.    Weight (lbs): $weight2
  141. SPORT EQUIPMENT
  142.    Package Type: $sport_equip2
  143.    Sport Ski Size: $sport_ski_size2
  144.    Shoe size: $shoe_size2
  145. DEMO SKIS
  146.    Package Type: $demo_equip2
  147.    Demo ski model: $demo_ski_model2
  148.    Demo Ski size: $demo_ski_size2
  149.    Shoe size: $shoe_size2
  150. SNOWBOARD
  151.    Package Type: $board_equip2
  152.    Board size: $board_size2
  153.    Shoe size: $shoe_size2
  154. KID'S EQUIPMENT (1 and under)
  155.    Junior Pakage: $jr_equip2
  156.    Ski Length: $jr_ski_size2
  157.    Shoe size: $shoe_size2
  158. Skier Type: $skier_type2
  159. Comments: $comment2
  160. ________________________________________
  161. RENTER #3
  162.    Name: $name3
  163.    Birth Date:  $age3
  164.    Height (ft/in): $height3
  165.    Weight (lbs): $weight3
  166. SPORT EQUIPMENT
  167.    Package Type: $sport_equip3
  168.    Sport Ski Size: $sport_ski_size3
  169.    Shoe size: $shoe_size3
  170. DEMO SKIS
  171.    Package Type: $demo_equip3
  172.    Demo ski model: $demo_ski_model3
  173.    Demo Ski size: $demo_ski_size3
  174.    Shoe size: $shoe_size3
  175. SNOWBOARD
  176.    Package Type: $board_equip3
  177.    Board size: $board_size3
  178.    Shoe size: $shoe_size3
  179. KID'S EQUIPMENT (12 and under)
  180.    Junior Pakage: $jr_equip3
  181.    Ski Length: $jr_ski_size3
  182.    Shoe size: $shoe_size3
  183. Skier Type: $skier_type3
  184. Comments: $comment3
  185. _____________________________
  186. RENTER #4
  187.    Name: $name4
  188.    Birth Date:  $age4
  189.    Height (ft/in): $height4
  190.    Weight (lbs): $weight4
  191. SPORT EQUIPMENT
  192.    Package Type: $sport_equip4
  193.    Sport Ski Size: $sport_ski_size4
  194.    Shoe size: $shoe_size4
  195. DEMO SKIS
  196.    Package Type: $demo_equip4
  197.    Demo ski model: $demo_ski_model4
  198.    Demo Ski size: $demo_ski_size4
  199.    Shoe size: $shoe_size4
  200. SNOWBOARD
  201.    Package Type: $board_equip4
  202.    Board size: $board_size4
  203.    Shoe size: $shoe_size4
  204. KID'S EQUIPMENT (12 and under)
  205.    Junior Pakage: $jr_equip4
  206.    Ski Length: $jr_ski_size4
  207.    Shoe size: $shoe_size4
  208. Skier Type: $skier_type4
  209. Comments: $comment4
  210.  
  211.  
  212. End of message
  213. ";
  214.  
  215. $subject = "Rental Reservation";
  216.  
  217. /* Send the message using mail() function */
  218. mail($myemail, $subject, $message);
  219.  
  220. /* Redirect visitor to the thank you page */
  221. header('Location: http://www.tetonvillagesports.com/thanks.html');
  222. exit();
  223.  
  224. /* Functions we used */
  225. function check_input($data, $problem='')
  226. {
  227.     $data = trim($data);
  228.     $data = stripslashes($data);
  229.     $data = htmlspecialchars($data);
  230.     if ($problem && strlen($data) == 0)
  231.     {
  232.         show_error($problem);
  233.     }
  234.     return $data;
  235. }
  236.  
  237. function show_error($myError)
  238. {
  239. ?>
  240.     <html>
  241.     <body>
  242.  
  243.     <b>Please correct the following error:</b><br />
  244.     <?php echo $myError; ?>
  245.  
  246.     </body>
  247.     </html>
  248. <?php
  249. exit();
  250. }
  251. ?>


Any thoughts would be appreciated
Dec 22 '09 #1
4 3199
Never mind I figured it out.
Dec 22 '09 #2
Atli
5,058 Expert 4TB
Hey.

How exactly is it now working? Can you elaborate on that please.

It would also help to see the HTML form (or a part of it, at least) that triggers this code. Since this is a browser issue, the problem is most likely not in the PHP code, but rather in the HTML form.


Also, since you have a LOT of input fields that you need to check...
Rather than type them out like that, manually writing each one into the check_input function and creating a global variable for each of them, you might want to try a more dynamic way, using arrays:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Set up a list of fields and their respective problem texts.
  3. $fields = array(
  4.     'name' => 'Enter a valid name!',
  5.     'email' => 'Your email address is invalid!',
  6.     'field3' => '',
  7.     'etc...' => ''
  8. );
  9.  
  10. // An array to hold the data for the fields.
  11. $data = array();
  12.  
  13. // Go through the field list and check the input for each of them.
  14. foreach($fields as $_name => $_problem) {
  15.     $data[$_name] = check_input($_POST[$_name], $_problem);
  16. }
  17.  
  18. // Do something with the data
  19. $text = <<<TEXT
  20. Some string that you would inject the data into:
  21. Name: {$data['name']}
  22. Email: {$data['email']}
  23. Field3: {$data['field3']}
  24. TEXT;
  25. ?>
This way you don't have to manually use the function for each field, and it's a little more organized. You could even pull the field list from another source. (Not that that's necessarily a good idea :P)

And by using the $data array like that, you don't clutter the global scope with random variables, which is good. (Keeping the global scope clear is always best)
Dec 22 '09 #3
Thanks for the input, I appreciate the help. The form is located at

http://www.tetonvillagesports.com/rentreso.html

The problem was resolved after I finally realized the Submit button was outside of the form tags. Everything (other than terrible coding) is now going great.
Dec 22 '09 #4
Atli
5,058 Expert 4TB
Glad to hear that.
It always seems that these sort of minor oversights cause the biggest problems :)
Dec 23 '09 #5

Post your reply

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

Similar topics

8 posts views Thread by Neil | last post: by
4 posts views Thread by Michael | last post: by
14 posts views Thread by Galen Somerville | last post: by
13 posts views Thread by deko | last post: by
1 post views Thread by XIAOLAOHU | last post: by

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.