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:

madmatt

Awesome is as awesome does.
Political Access
Joined
5 Apr 2002
Messages
13,314
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?
 

ray_gillespie

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

X-Istence

*
Political Access
Joined
5 Dec 2001
Messages
6,498
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!
 

ray_gillespie

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

ray_gillespie

OSNN Veteran Addict
Political Access
Joined
21 Mar 2002
Messages
1,693
Ur... bump! Anyone got any clues? I'm really struggling here :(
 

Xie

- geek -
Joined
29 Sep 2003
Messages
5,274
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). :)
 

Geffy

OSNN Veteran Addict
Joined
18 Mar 2002
Messages
7,805
does it work any better if you use real HTML and don't call exit()?
 

ray_gillespie

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

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.
Terrahertz wrote on Electronic Punk's profile.
Yo fellas!
Electronic Punk wrote on Sazar's profile.
Where are you buddy?
Perris Calderon wrote on Electronic Punk's profile.
Hey EP! All good with me, applying for Microsoft MVP right now, should have done this a while ago.

Notifications don't work, I only found your response by coming back to hunt up some threads, if you want, give me your email address so we can keep in touch easier!
Perris Calderon wrote on Electronic Punk's profile.
EP, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there!

Forum statistics

Threads
61,997
Messages
673,411
Members
5,590
Latest member
AntonioPR