简体   繁体   中英

Making sure users go through all set up pages in order

Users will enter information on 4 separate pages and click a 'continue' button that takes them to the next page.

I know I shouldn't prevent users from going back and entering information again, but I also need to set up something that doesn't allow users to do something like this:

www.page.com/setup1 -> www.page.com/setup3 -> www.page.com/setup4 -> www.page.com/setup2

Right now they could possibly go in any order they want if they just enter the URL.

$URL = $_SERVER["HTTP_REFERER"];

if($URL == " http://page.com/setup1 ") { blah blah }

I have a variable that handles the page that they came from, displaying certain information based on that. Is there a way to use that variable to handle my issue? If not, what is the best way to tackle this issue that might arise?

Instead of using four pages, write one and work with JQuery which enables you to show and hide successive fields etc. Use Ajax calls to provide any dynamic information such as selectors based on previous answers. Those can populate DIVs or SPANs which carry hidden default responses . There is at least one excellent Validate plugin that works with JQuery so you ensure all fields are correctly completed.

The advantages are an enhanced user experience, faster responses with reduced server load. It also means that if they want to change earlier data you can handle it all via Ajax and a good plan.

Before adopting the above approach, I used to use one framework page to post back to itself using hidden fields to control the flow, passing data with increasing numbers of post variables and nested if's. I made it managable with lots of include files to do the updates and new fields

My issue was solved through session variables. Each page has a session variable called 'steps'. Each step has a number associated with the page that they are on. If they previous session 'step' was not the correct one, it redirects them to the appropriate 'step' page.

$steps = $_SESSION['steps'];
$_SESSION['steps'] = 3

For example, this must be the 3rd page, or 'step' in the sign up process.

If $steps isn't == 3, I have code that redirects them to the start of the sign up process, destroys the session and they must sign up properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM