# Email Form Help

**URL:** <https://forum.kirupa.com/t/email-form-help/455809>\
**Category:** web dev\
**Created:** [January 2, 2015, 1:11pm UTC](https://forum.kirupa.com/t/email-form-help/455809 "2015-01-02T13:11:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ddgoldberg](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ddgoldberg/32/7134_2.png) [@ddgoldberg](https://forum.kirupa.com/u/ddgoldberg)\
**Post date:** [January 2, 2015, 1:11pm UTC](https://forum.kirupa.com/t/email-form-help/455809/1 "2015-01-02T13:11:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [January 2, 2015, 8:31pm UTC](https://forum.kirupa.com/t/email-form-help/455809/2 "2015-01-02T20:31:57Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![ddgoldberg](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ddgoldberg/32/7134_2.png) [@ddgoldberg](https://forum.kirupa.com/u/ddgoldberg)\
**Post date:** [January 2, 2015, 9:25pm UTC](https://forum.kirupa.com/t/email-form-help/455809/3 "2015-01-02T21:25:58Z")

</div>

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 = "blahblah@blahblah.net"; $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 } ?\>

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [January 4, 2015, 2:31am UTC](https://forum.kirupa.com/t/email-form-help/455809/4 "2015-01-04T02:31:12Z")

</div>

> [@ddgoldberg](#):
>
> header(‘Location: confirmation.htm’);

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!

---

<div class="post-metadata">

**Author:** ![ddgoldberg](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ddgoldberg/32/7134_2.png) [@ddgoldberg](https://forum.kirupa.com/u/ddgoldberg)\
**Post date:** [January 4, 2015, 12:15pm UTC](https://forum.kirupa.com/t/email-form-help/455809/5 "2015-01-04T12:15:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [January 5, 2015, 1:11am UTC](https://forum.kirupa.com/t/email-form-help/455809/6 "2015-01-05T01:11:58Z")

</div>

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