figster Posted June 22, 2006 Share Posted June 22, 2006 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 Quote Link to comment Share on other sites More sharing options...
AndyB Posted June 22, 2006 Share Posted June 22, 2006 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 Link to comment Share on other sites More sharing options...
figster Posted June 23, 2006 Author Share Posted June 23, 2006 [!--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? Quote Link to comment Share on other sites More sharing options...
AndyB Posted June 23, 2006 Share Posted June 23, 2006 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]<?phpif (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] Quote Link to comment Share on other sites More sharing options...
figster Posted June 23, 2006 Author Share Posted June 23, 2006 Thank you Super Guru, 'Preciate da help! Quote Link to comment Share on other sites More sharing options...
phpstuck Posted June 23, 2006 Share Posted June 23, 2006 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.