Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

session redirect

Status
Not open for further replies.

darryncooke

Technical User
May 6, 2009
308
US
Ok so here goes.

I have a form on a contact page that when submits will go to thank you page. However I do not want anyone to be able to access the thank you page unless the form is submitted. I figured the easiest way was to set a session variable on the contact page.

session_start();
$val = "temp";
session_register("val");

and then check and redirect on the thank you page.

session_start();
if (!isset($_SESSION['val']) || $_SESSION['val'] != "temp") {
header ("Location: index.php");

However everytime i go to test the form and submit i get redirected. If there is an easier way to accomplish what I am trying please let me know.

thank you

Darryn Cooke
| The New Orange County Graphic designer and Marketing and Advertising Consultant
| Marketing and Advertising blog
 
Why not display the "thank you" information on the page that handled the form? The form handling itself need not produce any output is all goes well. If something goes wrong (wrong or incomplete input, for instance), display the original form. If all goes well, display the "thank you" page.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
actually that is a very good idea. i ended up checking a form field as my validation but your idea is more efficient.

thank you

Darryn Cooke
| The New Orange County Graphic designer and Marketing and Advertising Consultant
| Marketing and Advertising blog
 
as an extension to auto-processing forms, read up on the despatch method of php scripting. once you have worked out that you control output, you quickly conclude that you only ever need one file. then the bubble bursts when you start trying to debug and manage memory allocation, but the principle remains sound!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top