高级会话脚本[关闭]

I was wondering if anybody knows how to make a script that would essentially save a percentage of how much you completed of say a test or something and when you go back to continue it will bring you to the page you're at. For example theres 5 pages, and you're on page 3 so it'll save as 60% and whenever you click continue it brings you to that page.

When I say advanced I mean like secure so you can't go skip to page 5 just by putting the url. For example at the head of each test page I would put this

if (session > 60%) {
header(Location: page3);
}

Do you guys know what I mean?

I was hoping somebody could just help me do this somehow and make it so it saves under the users profile and you can call the percentage whenever using a variable. Any ideas?

You're pretty close. First, check out any PHP Session Tutrorial to learn about them a bit.

You can access session variables with $_SESSION['keyname'] (after you've called session_start() on your page.

Simply save your progress as one of these, e.g. $_SESSION['progress'] = 60;

and evaluate by testing if the session is set (so you don't get an error), and then evaluate it as follows:

if ( isset($_SESSION['progress']) )
{
    //write your if (or switch) statement here
}

Let me know if that makes sense or if you have any questions :)