Jump to content


Photo

Direct user to thank you page after the add event


  • Please log in to reply
5 replies to this topic

#1 figster

figster
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 22 June 2006 - 11:12 PM

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
//    after add event        

        if(function_exists("AfterAdd"))

            AfterAdd();



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

    }

    

}

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

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 22 June 2006 - 11:22 PM

The standard php 'redirection' code would be:
header("Location: thankyoupage.html");

However 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.
Legend has it that reading the manual never killed anyone.
My site

#3 figster

figster
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 23 June 2006 - 12:23 AM

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

However 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?

#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 23 June 2006 - 12:30 AM

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:

<?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
}
?>

Legend has it that reading the manual never killed anyone.
My site

#5 figster

figster
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 23 June 2006 - 12:45 AM

Thank you Super Guru, 'Preciate da help!

#6 phpstuck

phpstuck
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 23 June 2006 - 12:47 AM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users