Jump to content

Archived

This topic is now archived and is closed to further replies.

figster

Direct user to thank you page after the add event

Recommended Posts

Ok, I'm gettin there, I have a form, and I get to post, only I want the user to be directed toa thank you page. This is my current after add event code snipet
[code]
//    after add event        

        if(function_exists("AfterAdd"))

            AfterAdd();



        $message="<div class=message><<< "."Record was added"." >>></div>";

    }

    

}
[/code]

That keeps them on the same page with Record was added in the top. How do I change that so they are directed to an html thank you page?

Thanks,
Figster

Share this post


Link to post
Share on other sites
The standard php 'redirection' code would be:
[code]header("Location: thankyoupage.html");[/code]

[b]However[/b] that will nor work if you have any previous output to the browser (which your sample code does). Maybe you could put the 'your record has been added' on the thank you page instead and as long as your script does not output to the browser, use the header function.

Share this post


Link to post
Share on other sites
[!--quoteo(post=387014:date=Jun 22 2006, 07:22 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 22 2006, 07:22 PM) [snapback]387014[/snapback][/div][div class=\'quotemain\'][!--quotec--]
The standard php 'redirection' code would be:
[code]header("Location: thankyoupage.html");[/code]

[b]However[/b] that will nor work if you have any previous output to the browser (which your sample code does). Maybe you could put the 'your record has been added' on the thank you page instead and as long as your script does not output to the browser, use the header function.
[/quote]

Wow that was a quick reply. Yes this returns the same form cleared, with the message "record has been added" How do I alter it from outputing the new form? I have this in the html sectionof my php page
<input type="Hidden" name="a" value="return"> does that cause the form to return empty?

Share this post


Link to post
Share on other sites
What do you want? To be re-directed to a thank you page as you asked in your first post, or to be brought back to the same page but without the form showing as you asked in your second post?

Assuming it's the latter, you want code like this:

[code]<?php
if (isset($_POST['submit')) {
// yes, the form was submitted
echo "Thanks, whatever";
} else {
// OK the form wasn't submitted so display it ...
echo "<form method="POST" action='". $_SERVER['PHP_SELF']. "'>";
// rest of the form
}
?>[/code]

Share this post


Link to post
Share on other sites
If you are wanting a whole new page that says thank you for submitting the blah_blah_blah then simply write your thank you page and use include_once on the page that processes your php. In other words make your form in html and make post the method with action set to process.php, make your php page process the posted data (do some checks if you want) and then echo a Thank you message if everything checks out. Only include the form if they forgot something on the form you require.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.