Mr Initial Man
07-02-2006, 04:43 AM
If I have a variable that I want to pass from one page to the next, what is the best way to do it?
The current method I am using is by URIs.
Page 1:
$chapter = $_GET['chapter'];
#...
echo('
#...
<li><a href="./glossary.php?fromchapter='.$chapter.'">Smilodon/English Dictionary</a></li>
#...
');
Page 2:
$from=$_GET['fromchapter'];
if(empty($from))
{
echo ('<li><a href="./fighter.php?chapter=0">Prologue</a></li>');
}
else
{
if($from==0)
{
echo ('<li><a href=./fighter.php?chapter='.$from.'>Back to Prologue</a></li>');
}
else
{
echo ('<li><a href=./fighter.php?chapter='.$from.'>Back to Chapter '.$from.'</a></li>');
}
}
But it seems to me there's got to be a better way to do this. Any suggestions?
The current method I am using is by URIs.
Page 1:
$chapter = $_GET['chapter'];
#...
echo('
#...
<li><a href="./glossary.php?fromchapter='.$chapter.'">Smilodon/English Dictionary</a></li>
#...
');
Page 2:
$from=$_GET['fromchapter'];
if(empty($from))
{
echo ('<li><a href="./fighter.php?chapter=0">Prologue</a></li>');
}
else
{
if($from==0)
{
echo ('<li><a href=./fighter.php?chapter='.$from.'>Back to Prologue</a></li>');
}
else
{
echo ('<li><a href=./fighter.php?chapter='.$from.'>Back to Chapter '.$from.'</a></li>');
}
}
But it seems to me there's got to be a better way to do this. Any suggestions?