Results 1 to 2 of 2

Thread: PHP form landing Page Help

  1. #1
    Join Date
    May 2010
    Thanked 0 Times in 0 Posts

    Default PHP form landing Page Help

    PHP form landing Page Help

    I have a contact form up and running, I want to change the landing page the user gets once their info has been submitted. I wasn't able to get the landing page to work, so for the meantime I set up an echo. Below is the code. Can anyone help me set up the landing page to you to a /thankyou.htm page? Thanks for the help.


    //--------------------------Set these paramaters--------------------------

    $subject = 'Request more info';

    $emailadd = '';

    $url = '';

    $req = '0';

    // --------------------------Do not edit below this line--------------------------

    $text = "Results from form:\n\n";

    $space = ' ';

    $line = '


    foreach ($_POST as $key => $value)


    if ($req == '1')


    if ($value == '')

    {echo "$key is empty";die;}


    $j = strlen($key);

    if ($j >= 20)

    {echo "Name of form element $key cannot be longer than 20 characters";die;}

    $j = 20 - $j;

    for ($i = 1; $i <= $j; $i++)

    {$space .= ' ';}

    $value = str_replace('\n', "$line", $value);

    $conc = "{$key}:$space{$value}$line";

    $text .= $conc;

    $space = ' ';


    mail($emailadd, $subject, $text, 'From: '.$emailadd.'');

    echo '<h1>Thank You!</h1>'.'<p>Your info has been received. We will contact you shortly.</p>';


  2. #2
    Join Date
    Mar 2006
    Illinois, USA
    Thanked 690 Times in 678 Posts


    There are two ways to do this:

    1. Use header() to give a redirect. This must be output before any text. This means you can only do it if there are no errors displayed to the user.

    2. Move your form checking code to the 'landing page'. Use thankyou.php as the action of the form. Done. Basically that's what you did above.
    This may be more complex if you want error checking: they need to return to the first page. You could have them use the back arrow.
    If not, you can merge all three into a single page:
    Display the form if no post data was sent.
    If post data was sent, check the data.
    If the data is wrong (if there's an error), display the form again (+error, +echo the submitted data back into the fields).
    If the data is correct, send the email and display thank you.

    The more complex method I just described is the best way to do it and allows the most freedom. It does, however, require a fairly strong understanding of how PHP works. It's not that it uses anything particularly advanced, but if you are having trouble understanding the general layout of PHP code it won't be easy for you to write it. Mostly, it's just a lot of code and conditionally output HTML blocks.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum


Posting Permissions

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