Email Form Help

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?

Thanks

Interesting. Can you post your full PHP code? (Feel free to remove things like your e-mail address so that spambots don’t find it so easily :P)

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 } ?>

Interesting. I don’t see anything out of the ordinary. Can you try out the PHP form with just the header line. Basically, this:

<?php
// redirect to confirmation
header('Location: confirmation.htm');
?> 

I am curious to know if this works just fine!

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 :stuck_out_tongue: 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)!