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

ray_gillespie

OSNN Veteran Addict
Political Access
Joined
21 Mar 2002
Messages
1,693
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:
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?

e.g.

PHP:
$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?
 
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 :)
 
The warning it gives you is exactly correct. The output was indeed already started.

Check line 1 for that PHP file:

/home/raygille/public_html/hawkins/test/submit_address.php

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

Code:
 <?php

instead of

Code:
<?php

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

<?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");
exit();

} else {
?>
<HTML>
<TITLE = "Submission Failed">

<BODY>
Submission failed.
</BODY>
</HTML>
<?php
}

?>
 
Last edited:
Ur... bump! Anyone got any clues? I'm really struggling here :(
 
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). :)
 
does it work any better if you use real HTML and don't call exit()?
 
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 profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back