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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.