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

Discussion in 'Web Design & Coding' started by ray_gillespie, Oct 25, 2007.

  1. ray_gillespie

    ray_gillespie Moderator Staff Member Political User

    Messages:
    1,692
    Location:
    Birmingham, UK
    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:

    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: Oct 30, 2007
  2. madmatt

    madmatt Bow Down to the King Political User

    Messages:
    13,312
    Location:
    New York
    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 likes this.
  3. ray_gillespie

    ray_gillespie Moderator Staff Member Political User

    Messages:
    1,692
    Location:
    Birmingham, UK
    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 :)
     
  4. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    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 likes this.
  5. ray_gillespie

    ray_gillespie Moderator Staff Member Political User

    Messages:
    1,692
    Location:
    Birmingham, UK
    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 -

     
    Last edited: Oct 27, 2007
  6. ray_gillespie

    ray_gillespie Moderator Staff Member Political User

    Messages:
    1,692
    Location:
    Birmingham, UK
    Ur... bump! Anyone got any clues? I'm really struggling here :(
     
  7. Xie

    Xie - geek - Subscribed User Folding Team

    Messages:
    5,275
    Location:
    NY, USA
    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). :)
     
    ray_gillespie likes this.
  8. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    does it work any better if you use real HTML and don't call exit()?
     
    ray_gillespie likes this.
  9. ray_gillespie

    ray_gillespie Moderator Staff Member Political User

    Messages:
    1,692
    Location:
    Birmingham, UK
    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!