I hav 2 of this script.The first one is to randomized an array.The second one is to navigate the array through a next button.
The problem is that i can't seem to pass the array to the second sscript to be executed.
All the others function seems to work well.
What wrong with my session?Is it what's making my script not working?
Please advise.
Thanks..
First script..
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<head>
<title>Title here!</title>
</head>
<body>
<?php @
session_start();
session_register("Rand[]");
function section($min,$max,$num_of_ques,$start_num){
global $Rand;
for($i=$min,$k=0;$k<=$max-$min;$i++,$k++){
$Rand_ques[$k]=("path$i"); //Assign path to array
}
srand((double) microtime()*10000000);
shuffle($Rand_ques);
for($i=$start_num,$k=0;$k<=$num_of_ques;$start_num++,$k++){ //Assign shuffled element into an array
$Rand[$start_num]=$Rand_ques[$k];
//echo "$Rand[$i]";
}
echo "\n";
unset($Rand_ques);
}
section($min=0,$max=99,$num_of_ques=14,$start_num=0); //section1=question 1-15
section($min=100,$max=199,$num_of_ques=22,$start_num=15); //section2a=question 16-38
section($min=200,$max=299,$num_of_ques=1,$start_num=38); //section2b=question 39-40
section($min=300,$max=399,$num_of_ques=9,$start_num=40); //section3=question 41-50
?>
<?
for($i=0;$i<50;$i++){
echo("$i=$Rand[$i]\n");
}
?>
<form action="next2.php" method="post">
<input type="hidden" name="i">
<input type="Submit" value="Start Test">
</form>
</body>
Second script..(next.php)
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<head>
<title>Title here!</title>
</head>
<body>
<?php
@
session_start();
session_register("i");
if ($i==49||$i==50){
$i=0;
echo "question $i==$Rand[$i]";
}
else if ($i>=0&&$i<49){
$i=$i+1;
echo "question $i==$Rand[$i]\n";
}
else if($i==50){
session_destroy();
}
$i=$i++;
echo "num==$i";
?>
<form action="next2.php" method="post">
<input type="hidden" name="i">
<input type="Submit" value="Next">
</form>
</body>