Jump to content

How should I execute this redirect?


tmallen

Recommended Posts

My server's been throwing errors when I send a late header after using the mail() function to send myself user feedback from a site contact form. I know that all headers have to be sent right away, so what's the way to redirect the user after the form's been sent successfully? Right now, I have the form and its script in the same file, so form action="contact.php" which is the form's page.

 

<?php
if (empty($errors)) {
  // $to, $subject, $message, and $headers are all assigned values

  // Send the email
  mail($to, $subject, $message, $headers);

  // This line seems to be generating header() errors.
  // Check header() functionality to correct
  header("Location: ./thanks.php");	
}
else {
  echo "\n<p>There were errors sending your message:</p>\n<ul>\n";
  foreach ($errors as $message) {
    echo "<li>$message</li>\n";
  }
  echo "</ul>\n";
}
?>

How do I send users to thanks.php after mail() works?

Link to comment
https://forums.phpfreaks.com/topic/105209-how-should-i-execute-this-redirect/
Share on other sites

Yes, i agree with u.

 

The function ob_start(). i have also used it so that while error occuring while generating output before header sends any information to other page.

 

Please suggest me if u people have any suggestion regarding it.

 

Me too also waiting

 

Thanks

Rahul - IT Professional.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.