youngros Posted January 18, 2010 Report Share Posted January 18, 2010 (edited) I successfully worked out how to set a hidden field and the php code to return the error if it was filled in using the if else statement. It all worked fine in testing, but when I transferred the code to the intended webpage it's not working. When submitting the form it returns a page not found 404 error and the url is showing the formmail.php suffix. Any ideas where I am going wrong? www.sanssouciwebdesign.com/weather/contact.php php code is <?php // Input Your Personal Information Here $mailto = '*' ; $from = "Madeira Weather" ; $formurl = "http://www.sanssouciwebdesign.com/weather/formmail.php" ; $errorurl = "http://www.sanssouciwebdesign.com/weather/error.php" ; $thankyouurl = "http://www.sanssouciwebdesign.com/weather/thankyou.php" ; // End Edit // prevent browser cache header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); function remove_headers($string) { $headers = array( "/to\:/i", "/from\:/i", "/bcc\:/i", "/cc\:/i", "/Content\-Transfer\-Encoding\:/i", "/Content\-Type\:/i", "/Mime\-Version\:/i" ); if (preg_replace($headers, '', $string) == $string) { return $string; } else { die('You think Im spammy? Spammy how? Spammy like a clown, spammy?'); } } $uself = 0; $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ; if (!isset($_POST['email'])) { header( "Location: $errorurl" ); exit ; } // Input Your Personal Information Here $name = remove_headers($_POST['name']); $email = remove_headers($_POST['email']); $subject = remove_headers($_POST['subject']); $comments = remove_headers($_POST['comments']); $http_referrer = getenv( "HTTP_REFERER" ); // End Edit if (!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i",$email)) { header( "Location: $errorurl" ); exit ; } // Input Your Personal Information Here if (empty($name) || empty($email) ||empty($comments)) { header( "Location: $errorurl" ); exit ; } // End Edit if ($subject == '') { //all your things here, e.g. add data to database, email, etc header( "Location: $thankyoururl" ); } else { header( "Location: $errorurl" ); exit ; } if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) { header( "Location: $errorurl" ); exit ; } if (get_magic_quotes_gpc()) { $comments = stripslashes( $comments ); } // sets max amount of characters in comments area (edit as nesesary) if (strlen($comments) > 1250) { $comments=substr($comments, 0, 1250).'...'; } // End Edit $message = "This message was sent from:\n" . "$http_referrer\n\n" . // Input Your Personal Information Here "Name: $name\n\n" . "Email: $email\n\n" . "Subject: $subject\n\n" . "Comments: $comments\n\n" . "\n\n------------------------------------------------------------\n" ; // End Edit mail($mailto, $from, $message, "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep ); header( "Location: $thankyouurl" ); exit ; ?> Edited January 18, 2010 by youngros Quote Link to comment Share on other sites More sharing options...
administrator Posted January 19, 2010 Report Share Posted January 19, 2010 Glad you solved it. Stefan Quote Link to comment 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.
Note: Your post will require moderator approval before it will be visible.