SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    SitePoint Enthusiast cubixstudios's Avatar
    Join Date
    Mar 2007
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy PHP problem with submission

    I am pretty new to the whole PHP and i'm trying to improve my skills. At present im developing a PHP form that sends the responses to an email address.

    It was all going well, the form sents to the email address but for some reason i can't get the web page to fwd to the thankyou.php page once the submission button has been pressed.

    The form page is on www.my-sd.com/way

    If you need me to post the coding i can.

    Thank you
    Cubix Studios web design-

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,805
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    Yes, please post the PHP part of your script and also I can't read the form on the page! The grey is way too light to be able to comfortably read it and the form fields merge in with the white background!
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Enthusiast cubixstudios's Avatar
    Join Date
    Mar 2007
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i see that as well, i need to change a lot of the css coding but wanted to get the php code correct first. i will post the php today
    Cubix Studios web design-

  4. #4
    SitePoint Enthusiast cubixstudios's Avatar
    Join Date
    Mar 2007
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    NEW code is below. same problems?
    Last edited by cubixstudios; Jun 30, 2007 at 16:13.
    Cubix Studios web design-

  5. #5
    SitePoint Evangelist optl's Avatar
    Join Date
    Oct 2004
    Location
    Washington DC
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does it give you an error message? The header() function won't work if output has already been sent to the browser.
    For the phrase "Bethesda home architect", my clients
    websites occupy 6 of the first 8 results
    on the 1st page of Google. My Secret SEO Strategy Revealed

  6. #6
    SitePoint Enthusiast cubixstudios's Avatar
    Join Date
    Mar 2007
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes, after you submit
    Cubix Studios web design-

  7. #7
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,805
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    The error message gives a clue as to where the problem is coming from. I ran a test through the form and it gave:

    Code:
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/g/w/y/gwyndy111/html/way.php:1) in /home/content/g/w/y/gwyndy111/html/way.php on line 77
    What this means is that on line 1 of way.php there is some kind of output.
    Output is defined as blank space, characters or anything that can be interpretted by the browser.

    eg
    Code:
      <?php .... ?>
    the space before the <?php is classed as output and will throw the error. Make sure there is NOTHING on line 1 of the php file that is echoed or has space.

    If you want to post your code as is, please use the [code][/code] or [php][/php] tags
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  8. #8
    SitePoint Enthusiast cubixstudios's Avatar
    Join Date
    Mar 2007
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    exact code used

    removal of code
    Last edited by cubixstudios; Jun 30, 2007 at 18:42. Reason: dont want to keep live code online
    Cubix Studios web design-

  9. #9
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok here is the solution that will work every time. Instead of using one page and sending post data to the same page use a page handler ! Just take out all of your post handling code and place it into a php file, call it mail_frm_handler. Process your post data on this page and then use the header function after you are through to go to the thank you page. Oh and you might try taking your url out of the variable and placing it directly in the function. I know there is supposed to be variable expansion because it is double quotes, but I am not sure that applies within a function.
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  10. #10
    SitePoint Enthusiast cubixstudios's Avatar
    Join Date
    Mar 2007
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanksfor the help byron but its way too complecated for me.... im pretty new to all this php. This form is the most complexed ive done so far
    Cubix Studios web design-

  11. #11
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That will help simplify your code to split it into one page for the form and another to handle your post submitted data.
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  12. #12
    SitePoint Enthusiast cubixstudios's Avatar
    Join Date
    Mar 2007
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    isnt there a way i can just remove the header line and then redirect the page to the thank you page?
    Cubix Studios web design-

  13. #13
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can do a basic redirect with HTML.

    Replace this:
    header("Location:$thankyoupage");

    With:
    Code:
    ?>
    <html><head>
    <meta http-equiv="REFRESH" content="0;url=<?php echo $thankyoupage ?>"></head>
    <body></body>
    </html>
    <?php
    die();

    Again though, the header() redirect should work as long as you have NO spaces or newlines before the first <?.

  14. #14
    SitePoint Enthusiast cubixstudios's Avatar
    Join Date
    Mar 2007
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thansk byron, ive taken the code down and ill start working on the way you suggested.
    Cubix Studios web design-

  15. #15
    SitePoint Enthusiast cubixstudios's Avatar
    Join Date
    Mar 2007
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i just went through the code line by line making sure everything was correct and i seemed to add an extra ; on line 30 which once removed allowed the code to work correctly.

    thanks for your help on this its much appriciated.
    Cubix Studios web design-


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •