php - Form 'submit' button always ending with error -


i've created simple contact form using this sample css-tricks. worked great until customised contactthanks.php page (confirmation of successful form submission). every time user hits 'submit', redirected error page.

live page: alookat.org/contact.html (feel free test form).

the following contactengine.php broke things after edited it. removed telephone input , replaced website. re-orded inputs.

<?php  $emailfrom = "info@example.com"; $emailto = "my.personal.email.was.here.for.testing@gmail.com"; $subject = "thanks contacting us"; $name = trim(stripslashes($_post['name']));   $email = trim(stripslashes($_post['email']));  $website = trim(stripslashes($_post['website'])); $message = trim(stripslashes($_post['message']));   // validation $validationok=true; if (!$validationok) {   print "<meta http-equiv=\"refresh\" content=\"0;url=error.htm\">";   exit; }  // prepare email body text $body = ""; $body .= "name: "; $body .= $name; $body .= "\n"; $body .= "email: "; $body .= $email; $body .= "\n"; $body .= "website: "; $body .= $website; $body .= "\n"; $body .= "message: "; $body .= $message; $body .= "\n";  // send email  $success = mail($emailto, $subject, $body, "from: <$emailfrom>");  // redirect success page  if ($success){   print "<meta http-equiv=\"refresh\" content=\"0;url=php\contactthanks.php\">"; } else{   print "<meta http-equiv=\"refresh\" content=\"0;url=error.htm\">"; } ?> 

thanks help. reading.

using

<meta http-equiv=\"refresh\" content=\"0;url=error.htm\">"; 

is nasty way of moving user new page.

you in php use header() function instead.

header('location: php/contactthanks.php'); exit; 

this way send header tells browser go page, rather whole page of html.

you can use in 3 place using <meta http-equiv...> tags


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -