Re: Re: Incrementing a page link, refresh problem

From: Date: Tue, 08 Aug 2006 14:07:05 +0000
Subject: Re: Re: Incrementing a page link, refresh problem
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-240320@lists.php.net to get a copy of this message
Ivo F.A.C. Fokkema wrote: > On Tue, 08 Aug 2006 14:54:08 +0100, Ross wrote: > >> I write a session to determine what module a user is on >> >> >> $_SESSION['module_no']==1; >> >> when they get to the end of the module I want to create a dynamic link to >> the next module >> >> $increment = $_SESSION['module_no']++; >> $link= "../module_$increment.php"; >> >> The problem is every time the page is refreshed $increment is added to. Any >> ideas or ways around this. I do not want to create an 'end_of module.php' >> page for every module. >> >> R. > > Don't you mean to do: > > $increment = $_SESSION['module_no'] + 1; yeah and then somewhere in each 'module_X.php' page you would do something like: setSessionModuleNumber(); and a seperate file with a function [something] like so: function setSessionModuleNumber() { $_SESSION['module_no'] = intval(str_replace('module_', basename($_SERVER['PHP_SELF']))); } ... just an idea > > Your code increments $_SESSION['module_no'] on every refresh... >

« previous php.general (#240320) next »