Jump to content

Direct user to thank you page after the add event


figster

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
Link to comment
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.
Link to comment
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?
Link to comment
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]
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.