• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Help! I'm going crazy!! PHP form problem!!


OSNN Veteran Addict
Political User
Hi guys,

Please help! This is driving me nuts!!!!!!!!!! :dead::laugh::lick::dead::laugh::dead::lick:

Basically, I have one website www.clarebray.co.uk which is up and running 100%. As part of that website, I have a 'contact me' form which is used to email enquiries to a certain email address. This is all fine and working.

I'm now designing another, similar website, for someone else - www.cllrkenhawkins.com I have literally cut and pasted exactly the same form code and just amended the email address and other links. However, every time I submit anything through the form, it comes up with this error:

Warning: Cannot modify header information - headers already sent by (output started at /home/raygille/public_html/hawkins/test/submit_address.php:1) in /home/raygille/public_html/hawkins/test/submit_address.php on line 23
It still sends the form details but won't redirect to the thankyou.php page.

How can this be? I've checked and checked and checked, everything is how it should be compared to the first website. I've set up a test page at www.cllrkenhawkins.com/test/contactme.php

What's even more crazy is that if I choose the email address that the forms sends from to be anything@cllrkenhawkins.com it comes from raygille@host120.hostmonster.com for some reason. Any clues? On the first website, this problem doesn't occur at all.

Please help, I'm going mad!!!!!:dead::dead::dead:

Millions of cookies for anyone who can help!
Last edited:


Bow Down to the King
Political User
Are you using cookies? Code for setting cookies needs to be set before the <html> tag (technically before the <head> tag).

Are you setting the from variable correctly?


$from     = "From: $name <$email>\nReply-To: $email\nMIME-Version: 1.0\nContent-type: text/html; charset=iso-8859-1\n";
mail($mailto, $subject, $msgBody, $from);
Or something similar?


OSNN Veteran Addict
Political User
No, not using cookies that I'm aware of. What's strange is that the two websites are in essence the same but the code only works on one of them. Hmmmmmm. You can have some cookies anyway just for bringing up the subject :)


Political User
The warning it gives you is exactly correct. The output was indeed already started.

Check line 1 for that PHP file:


I bet you have a space before you open your PHP tags:

instead of

PHP reads that first space, sends it off to get sent out to Apache, and that gets sent to the users browser first, then when you try to set the header, you get that error because Apache/PHP already sent the required headers to be able to send that first extra white space.

Make sure all your scripts that have to set headers have no output before the header is set, or do some buffering using PHP so any output is buffered and then later you send it when you are damn well ready!


OSNN Veteran Addict
Political User
Alas no! I have checked this and there is nothing, not even a space, before the "<?php". The email problem seems to have resolved itself, I think this is probably because I only bought the domain this morning and it's not had time to update DNS servers or something.

But this problem with the code still holds on tight. I really can't think what else I can do! Thanks for looking into this for me though, it's appreciated.

EDIT: This is the full code from submit_php -


$headers = 'From: website (at) cllrkenhawkins.com' . "\r\n" .
'Reply-To: website (at) cllrkenhawkins.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

$message = 'Name: ' . $_POST['name'] . "\r\n" .'Phone Number: ' . $_POST['telephone'] . "\r\n" .'Address: ' . $_POST['address'] . "\r\n" .'Comments: ' . $_POST['Comments'];

$success = mail('ray_gillespie (at) hotmail (dot) com', 'Enquiry from website', $message, $headers);

if($success) {
header("Location: thankyou.php");

} else {
<TITLE = "Submission Failed">

Submission failed.

Last edited:


- geek -
Other then what X already said I can't help you other then suggesting that you copy/paste it into a new file to make sure all white space before and after the closing tags is gone.

I would also suggest replacing your email addy with a fake before the spam spiders get it (if they haven't already). :)


OSNN Veteran Addict
Political User
Well, what I did in the end was rebuild the whole thing with brand new code which was exactly the same as before but on a new sub-domain. I don't know what changed (and to be honest I don't care :)) but it now works perfectly!

I just changed the domain to route directly to the new sub-domain et voila, back online and fully working :)

I must say, that's one of the strangest problems I've ever had. Thanks for all the tips guys!

Members online

No members online now.

Latest posts

Latest profile posts

Hello, is there anybody in there? Just nod if you can hear me ...
What a long strange trip it's been. =)

Forum statistics

Latest member