fatmikey Posted September 29, 2008 Share Posted September 29, 2008 Hope you can help...I have this script that at some point used to work but I did somthing and now it won't work, it keeps generating an error condition. Hope you can help me figure this out, I have a simple input form in the front end which calls this PHP script when the user hits submit, here is the script: <?php // get posted data into local variables $Email = Trim(stripslashes($_POST['Email'])); $EmailTo = "register@ottawapolefitness.com, hewittm@gmail.com"; $Subject = "Registration"; $FirstName = Trim(stripslashes($_POST['FirstName'])); $LastName = Trim(stripslashes($_POST['LastName'])); $Telephone = Trim(stripslashes($_POST['Telephone'])); $Address = Trim(stripslashes($_POST['Address'])); $City = Trim(stripslashes($_POST['City'])); $Province = Trim(stripslashes($_POST['Province'])); $PostalCode = Trim(stripslashes($_POST['PostalCode'])); $Class = Trim(stripslashes($_POST['Class'])); $Level = Trim(stripslashes($_POST['Level'])); $Day = Trim(stripslashes($_POST['Day'])); $How = Trim(stripslashes($_POST['How'])); $Comments = Trim(stripslashes($_POST['Comments'])); // validation $validationOK=true; if (Trim($Email)=="") { print "<meta http-equiv=\"refresh\" content=\"0;URL=error1.htm\">"; exit; } else { $validationOK=true;; } if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $Email)) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error1.htm\">"; exit; } else { $validationOK=true; } if (Trim($Email)=="") { print "<meta http-equiv=\"refresh\" content=\"0;URL=error1.htm\">"; exit; } else { $validationOK=true; } if (strlen($Telephone) < 10) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error2.htm\">"; exit; } else { $validationOK=true; } if (Trim($FirstName)=="") { print "<meta http-equiv=\"refresh\" content=\"0;URL=error3.htm\">"; exit; } else { $validationOK=true; } if (Trim($LastName)=="") { print "<meta http-equiv=\"refresh\" content=\"0;URL=error4.htm\">"; exit; } else { $validationOK=true; } if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "First: "; $Body .= $FirstName; $Body .= "\n"; $Body .= "Last: "; $Body .= $LastName; $Body .= "\n"; $Body .= "Telephone: "; $Body .= $Telephone; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Address: "; $Body .= $Address; $Body .= "\n"; $Body .= "City: "; $Body .= $City; $Body .= "\n"; $Body .= "Province: "; $Body .= $Province; $Body .= "\n"; $Body .= "PostalCode: "; $Body .= $PostalCode; $Body .= "\n"; $Body .= "Class: "; $Body .= $Class; $Body .= "\n"; $Body .= "Level: "; $Body .= $Level; $Body .= "\n"; $Body .= "Day: "; $Body .= $Day; $Body .= "\n"; $Body .= "How: "; $Body .= $How; $Body .= "\n"; $Body .= "Comments: "; $Body .= $Comments; $Body .= "\n"; if ($Class == "Workshop") { mail($EmailTo, $Subject, $Body, "From: <$Email>"); print "<meta http-equiv=\"refresh\" content=\"0;URL=checkout.htm\">"; exit; } // send email $success = mail($EmailTo, $Subject, $Body, "From: <$Email>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.htm\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> The online form is here www.ottawapolefitness.com/test/registration.htm Not sure if this is relevant but here is the output from the error_log on the host: [29-Sep-2008 16:35:52] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-zts-20060613/mysql.so' - /usr/local/lib/php/extensions/no-debug-zts-20060613/mysql.so: Undefined symbol "core_globals" in Unknown on line 0 Quote Link to comment https://forums.phpfreaks.com/topic/126353-solved-php-script-keeps-generating-an-error-message/ Share on other sites More sharing options...
DarkWater Posted September 29, 2008 Share Posted September 29, 2008 1) Enclose your code in tags or else no one will read it. 2) What's the error....? Quote Link to comment https://forums.phpfreaks.com/topic/126353-solved-php-script-keeps-generating-an-error-message/#findComment-653400 Share on other sites More sharing options...
ratcateme Posted September 29, 2008 Share Posted September 29, 2008 try changing your redirects to error1 to some text that says what if is failing so you know where the problem is. Scott. Quote Link to comment https://forums.phpfreaks.com/topic/126353-solved-php-script-keeps-generating-an-error-message/#findComment-653412 Share on other sites More sharing options...
fatmikey Posted September 29, 2008 Author Share Posted September 29, 2008 Thanks, I put the enclosed the code. The problem with this script is it keeps jumping to the error on the very last print statement. No matter how I compete the online form and after the validation it always calls the error.htm page. There is no actual error message, it's just the code is acting up. Mikey Quote Link to comment https://forums.phpfreaks.com/topic/126353-solved-php-script-keeps-generating-an-error-message/#findComment-653415 Share on other sites More sharing options...
gaza165 Posted September 29, 2008 Share Posted September 29, 2008 just a tip.... dont use striplashes... isnt that reliable anymore use mysql_real_esacape_string($string); Gaz Quote Link to comment https://forums.phpfreaks.com/topic/126353-solved-php-script-keeps-generating-an-error-message/#findComment-653417 Share on other sites More sharing options...
fatmikey Posted September 29, 2008 Author Share Posted September 29, 2008 I have different error messages on different error pages called error1.htm error2.htm and error.htm so I am pretty sure it's the last print statement. I did replace the print with text to verify the correct place and it is. Quote Link to comment https://forums.phpfreaks.com/topic/126353-solved-php-script-keeps-generating-an-error-message/#findComment-653419 Share on other sites More sharing options...
graham23s Posted September 29, 2008 Share Posted September 29, 2008 your trimming data twice to Graham Quote Link to comment https://forums.phpfreaks.com/topic/126353-solved-php-script-keeps-generating-an-error-message/#findComment-653429 Share on other sites More sharing options...
fatmikey Posted September 29, 2008 Author Share Posted September 29, 2008 Do you see anything out of whack that would cause this script to actualy fail at the last print statement? Quote Link to comment https://forums.phpfreaks.com/topic/126353-solved-php-script-keeps-generating-an-error-message/#findComment-653451 Share on other sites More sharing options...
ratcateme Posted September 29, 2008 Share Posted September 29, 2008 it fails because your email fails. so then check the mail() configuration to see where the problem is Scott. Quote Link to comment https://forums.phpfreaks.com/topic/126353-solved-php-script-keeps-generating-an-error-message/#findComment-653473 Share on other sites More sharing options...
fatmikey Posted September 30, 2008 Author Share Posted September 30, 2008 Yep. that's where the problem was, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/126353-solved-php-script-keeps-generating-an-error-message/#findComment-654332 Share on other sites More sharing options...
.josh Posted October 1, 2008 Share Posted October 1, 2008 so...fatmikey, why did you report this thread? Quote Link to comment https://forums.phpfreaks.com/topic/126353-solved-php-script-keeps-generating-an-error-message/#findComment-654644 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.