Remember Which Step in Tutorial

Hi everyone, one of my friends would like to make an introductory tutorial on how to use their website. She wanted to make it kind of fun by having a ‘character’ be the tutorial guide. She has 5 characters she’d like the computer to randomly assign to new players. And since she doesn’t really know PHP well, she’s come to me. I don’t know PHP well but I know it better than her, so here I am asking for a bit of help. Below is my logic.

  1. Upon registering, a random number (1-5) is generated and inserted in to the user’s table in the DB.

[code]$guide = rand(1, 5);

mysql_query(“INSERT INTO members (email, pass, pass_extra, user, pname, joindate, ip_address, activecode, guide)
VALUES (’$email’, ‘$pass’, ‘$salt’, ‘$user’, ‘$pname’, NOW(), ‘$ip’, ‘$key’, ‘$guide’)”)
or die ('cannot create a new member ’ . mysql_error());[/code]

  1. Upon logging in grab the $guide value

$player = mysql_query("SELECT mid, user, pass, pass_extra, guide FROM members WHERE binary user = '$user'"); $player = mysql_fetch_assoc($player);

Now here’s where I’m stumped on what to use. Is it possible to use php for this next step, or is it easier in some other form of code?

  1. Have a file included called guide.php where there is a list of text to choose from (below). And then somehow display that message.

if($guide == 1){ echo 'Howdy!'; } if($guide == 2){ echo 'Hello'; } if($guide == 3){ echo 'Hi'; } if($guide == 4){ echo 'Bonjour!'; } if($guide == 5){ echo 'Hola'; }

However this is a tutorial, remember, so there needs to be a link they click on called ‘Next’ which displays different information. Guide 1, step 1: “Hi! Ready to begin?” user hits the next button Guide 1, step 2: “Okay, so click on this button” etc

How would I be able to incorporate that, and have the computer remember which step they were on?

Save it as a cookie or session variable.

You could add a field to the members-table, call it ‘laststep’ and store the last served step inthere.
That way it would survive cookie-cleanups, session-expiration and even browser-changes.

( Personally I’d also put the guide-steps in the database )

Hope it helps,
O.

Thanks! What would the kind of php process be? I have made a time-out session if the user goes inactive, and of course if they log out, so I would put the process there.

You mean:When do I update the field in the member record?
I’d say every time you serve the member a new tutorial step. That way the record in your database is always up-to-date.

Good luck,
O. :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service