javascript - Redirect sendmail to page instead of error message -


i've tried many variables , been @ hours , hours know simple haha, cannot work... need do, is... when form completed have redirected page instead of normal error message.

your appreciated.

<?php //retrieve form data.  //get - user submitted data using ajax //post - in case user not support javascript, we'll use post instead $name = ($_get['name']) ? $_get['name'] : $_post['name']; $phone = ($_get['phone']) ? $_get['phone'] : $_post['phone']; $email = ($_get['email']) ?$_get['email'] : $_post['email']; $comment = ($_get['comment']) ?$_get['comment'] : $_post['comment'];  //flag indicate method uses. if post set 1  if ($_post) $post=1;  //simple server side validation post data, of course, should validate email if (!$name) $errors[count($errors)] = 'please enter name.'; if (!$phone) $errors[count($errors)] = 'please enter contact number.'; if (!$email) $errors[count($errors)] = 'please enter email.';  if (!$comment) $errors[count($errors)] = 'please enter comment.';   //if errors array empty, send mail if (!$errors) {      //recipient - replace email here     $to = 'me@myemail.com';      //sender - form     $from = $name . ' <' . $email . '>';      //subject , html message     $subject = 'message ' . $name;      $message = 'name: ' . $name . '<br/><br/>                 phone: ' . $phone . '<br/><br/>                 email: ' . $email . '<br/><br/>                      message: ' . nl2br($comment) . '<br/>';      //send mail     $result = sendmail($to, $subject, $message, $from);      //if post used, display message straight away     if ($_post) {         if ($result)              echo 'thank you! have received message.';         else              echo 'sorry, unexpected error. please try again later';          //else if used, return boolean value              //ajax script can react accordingly             //1 means success, 0 means failed     } else {         echo $result;        }      //if errors array has values } else {     //display errors message     ($i=0; $i<count($errors); $i++) echo $errors[$i] . '<br/>';     echo '<a href="index.html">back</a>';     exit; }   //simple mail function html header function sendmail($to, $subject, $message, $from) {     $headers = "mime-version: 1.0" . "\r\n";     $headers .= "content-type:text/html;charset=iso-8859-1" . "\r\n";     $headers .= 'from: ' . $from . "\r\n";      $result = mail($to,$subject,$message,$headers);      if ($result)          return 1;     else          return 0; } 


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -