Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-16-2012, 10:31 PM   PM User | #1
grundig
New Coder

 
Join Date: Oct 2012
Posts: 13
Thanks: 4
Thanked 0 Times in 0 Posts
grundig is an unknown quantity at this point
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
grundig is offline   Reply With Quote
Old 12-17-2012, 12:39 AM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
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
__________________
"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

Last edited by AndrewGSW; 12-17-2012 at 12:48 AM.. Reason: More likely to be GET than POST
AndrewGSW is offline   Reply With Quote
Users who have thanked AndrewGSW for this post:
grundig (12-17-2012)
Old 12-17-2012, 07:54 PM   PM User | #3
grundig
New Coder

 
Join Date: Oct 2012
Posts: 13
Thanks: 4
Thanked 0 Times in 0 Posts
grundig is an unknown quantity at this point
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.
grundig is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:05 PM.


Advertisement
Log in to turn off these ads.