I have the following code-
<?php
$input = array();
for($i=0; $i<15; $i++)
$input[]=$i;
shuffle($input);
$file="data.xml";
$test= new SimpleXMLElement($file, null, true); ?>
<?php
for($i=0; $i<5; $i++) {
?>
<form action="submit.php" method="post" id="form">
<p id="ques"><?php echo $test->easy->question[$input[$i]]->ques?> </p>
<p id="option"><input type="radio" name="<?php echo $input[$i]?>" value="0" /><?php echo $test->easy->question[$input[$i]]->option[0]; ?></p>
<p id="option"><input type="radio" name="<?php echo $input[$i]?>" value="1" /><?php echo $test->easy->question[$input[$i]]->option[1]; ?></p>
<p id="option"><input type="radio" name="<?php echo $input[$i]?>" value="2" /><?php echo $test->easy->question[$input[$i]]->option[2]; ?></p>
<p id="option"><input type="radio" name="<?php echo $input[$i]?>" value="3" /><?php echo $test->easy->question[$input[$i]]->option[3]; ?></p>
</form>
<?php } ?>
Now, in the submit page how do I use the input name $input[i] ?
$_POST[what do I write here?] ?
You initialized
$inputto contain0..15in a random order. Next you chose the first 5 entries via$i, soinput[$i]will have a random number between 0 and 15. If you use this as anameattribute, you will not have a constant set of POST parameters to use.So I suggest you do something like:
In the submit page read
$_POST['question'], this gives you back your$i, then read$_POST["q$i"]