Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Success Page

  1. #1
    New Coder
    Join Date
    Oct 2012
    Posts
    13
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Success Page

    I have 2 forms on my site Contact_Us.php and Register.php. I have a success.php page that when The user fills out the contact form displays the message Thank you $first_name for contacting us. Can I get the same success page to display Thank you $first_name for registering when the user fills out the registration.php form

    is the code something like

    }
    else
    {

    Any help apreciated

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Yes you can, and using else as you proposed.

    Depending on your current code(?) you could either:

    Use $_SERVER['HTTP_REFERER'] (sic.) to discover which page requested this page. This method is not ideal, and the referrer-url needs to be parsed - that is, split up to extract the host and page details;

    More simply, include a hidden form-field that contains the value of either 'contact' or 'register', or append one of these words as part of a querystring. This can be read by the success page:

    PHP Code:
    if ($_GET['referee'] && !empty($_GET['referee'])) {
        
    $referee $_GET['referee'];
        if (
    $referee == 'contact') {
            echo 
    "Well done!";
        } else if (
    $referee == 'register') {
            echo 
    "Yo there!";
        }

    However, I would suggest that you continue to keep them as separate pages as you are likely to need to do different things according to whether the page is in response to a contact or registration, and to perhaps process data in different ways, or provide quite different page-content. Even if you are not doing this now, you are likely to do so at some point. Besides, it's not difficult to maintain two separate success pages. Not a big deal, but I thought it worth mentioning. YPYM
    Last edited by AndrewGSW; 12-17-2012 at 12:48 AM. Reason: More likely to be GET than POST
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • Users who have thanked AndrewGSW for this post:

    grundig (12-17-2012)

  • #3
    New Coder
    Join Date
    Oct 2012
    Posts
    13
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thank's very much Andrew. I have to admit I was thinking it may just be easier to use more than one success page. As you say they don't take a lot of maintaining and its easier to describe what you want from each form that way.

    Thanks for your help anyway, at least I now know that it can be done and most importantly I was thinking along the right lines.


  •  

    Posting Permissions

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