In trying to use the email contact form on your site , I get the following error when the send button is pushed:
Warning: Cannot modify header information - headers already sent by (output started at /home/telact5/public_html/tinasrangegear.com/mailer.php:10) in /home/telact5/public_html/tinasrangegear.com/mailer.php on line 28
This is, in fact, the line in mailer.php which points to the confirmation page (which exists):
header(‘Location: confirmation.htm’);
The email does send and can be received but the confirmation page will not display. Any idea why this doesn’t work?
Kirupa, thanks for the reply. Not sure how to attach a file to a post so am copying the .php file contents here. And yes, I’ve removed the URLs. As I said, the confirmation page does exist with the correct name (confirmation.htm). Any ideas?
Untitled Document
<?php
if(isset($_POST['submit'])) {
$to = "[email protected]";
$subject = "An Email from blahblah";
// data the visitor provided
$name_field = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
$email_field = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
$comment = filter_var($_POST['comment'], FILTER_SANITIZE_STRING);
//constructing the message
$body = " From: $name_field\n\n E-Mail: $email_field\n\n Message:\n\n $comment";
// ...and away we go!
mail($to, $subject, $body);
// redirect to confirmation
header('Location: confirmation.htm');
} else {
// handle the error somehow
}
?>
Kirupa - I did as you suggested and used only the header and received the exact same error message. I am starting to think this has something to do with how my server is handling php. I use Inmotion for hosting and will call their tech department later today to see if they have run into this problem before. Maybe they have a custom php script which needs to be used.
Can’t thank you enough for your time and help. I’ll let you know if I come up with any answers. Best wishes, David
Yep - that does sound like a server configuration issue Let me know what they end up saying. If they can’t make any modifications, we can look at some alternatives (if there are any)!
Creating engaging and entertaining content for designers and developers since 1998.