Hi - I am having a lot of trouble upgrading a PHP form to the newest PHP language. Any help would be greatly appreciated.
Here is the url: http://www.haepibean.com
and here is the code:
Code:<script language="JavaScript"> <!-- /*********************************************** * Required field(s) validation v1.10- By NavSurf * Visit Nav Surf at http://navsurf.com * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/ function formCheck(formobj){ // Enter name of mandatory fields var fieldRequired = Array("your_email", "age_years", "age_months"); // Enter field description to appear in the dialog box var fieldDescription = Array("Email:", "Years:", "Months:"); // dialog message var alertMsg = "Please complete the following fields:\n"; var l_Msg = alertMsg.length; for (var i = 0; i < fieldRequired.length; i++){ var obj = formobj.elements[fieldRequired[i]]; if (obj){ switch(obj.type){ case "select-one": if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "select-multiple": if (obj.selectedIndex == -1){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "text": case "textarea": if (obj.value == "" || obj.value == null){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; default: } if (obj.type == undefined){ var blnchecked = false; for (var j = 0; j < obj.length; j++){ if (obj[j].checked){ blnchecked = true; } } if (!blnchecked){ alertMsg += " - " + fieldDescription[i] + "\n"; } } } } if (alertMsg.length == l_Msg){ return true; }else{ alert(alertMsg); return false; } } // --> </script> <form name="dform" action="email.php" method="post" onsubmit="return formCheck(this);"> <table> <tr> <td> <input type="hidden" value="thrive@haepibean.com" name="email" /> <input type="hidden" value="Contact Form Submission" name="subject"/> email : <input type="text" name="your_email" style="width:215px; height:15px; overflow:hidden; background-color:#ffffff; border:solid; border-width:1px; border-color:#6986B7; font-family: Arial, Helvetica, sans-serif; color:#6986B7; font-size:14; letter-spacing:1px;" /> child’s age: years <select name="age_years"> <option value="0" style="background-color:#ffffff;">0</option> <option value="1" style="background-color:#ffffff;">1</option> <option value="2" style="background-color:#ffffff;">2</option> <option value="3" style="background-color:#ffffff;">3</option> <option value="4" style="background-color:#ffffff;">4</option> <option value="5" style="background-color:#ffffff;">5</option> </select> months <select name="age_months"> <option value="0" style="background-color:#ffffff;">0</option> <option value="1" style="background-color:#ffffff;">1</option> <option value="2" style="background-color:#ffffff;">2</option> <option value="3" style="background-color:#ffffff;">3</option> <option value="4" style="background-color:#ffffff;">4</option> <option value="5" style="background-color:#ffffff;">5</option> <option value="6" style="background-color:#ffffff;">6</option> <option value="7" style="background-color:#ffffff;">7</option> <option value="8" style="background-color:#ffffff;">8</option> <option value="9" style="background-color:#ffffff;">9</option> <option value="10" style="background-color:#ffffff;">10</option> <option value="11" style="background-color:#ffffff;">11</option> <option value="12" style="background-color:#ffffff;">12</option> </select> </td> <td> <input type="image" src="images/hb-learnmorebutton.png" value="submit" name="submit" style="border:none; background:#ffffff; margin-left:10px;" /> </td></tr></table> </form>
email.php:
Code:<?php if(isset($_POST['submit'])) { # Form declarations $to = "thrive@haepibean.com"; $subject = "Contact Form Submission"; $from = "Contact Form Submission"; $your_email_field = $_POST['your_email']; $age_years_field = $_POST['age_years']; $age_months_field = $_POST['age_months']; $body = " Email: $your_email_field\n Age Years: $age_years_field\n Age Months: $age_months_field\n"; $SpamErrorMessage = "No Websites URLs permitted"; if (preg_match("/http/i", "$your_email_field")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http/i", "$age_years_field")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http/i", "$age_months_field")) {echo "$SpamErrorMessage"; exit();} $success = mail($to, $subject, $body, "From: \"$your_email\" <$your_email_field>"); } if ($success){ header('Location: http://haepibean.com/thankyouemail.html'); } else { header('Location: http://haepibean.com/emailerror.html'); } ?>



Reply With Quote


Bookmarks