i have this code. the looping code. but i dont know how to pass the value to the next page. help me please! :P

<?php

$req = $_POST['req'];

echo "<form>";


echo "</form>";
$i=1;

while($i <= $req) {
    echo "<label>Requirement " . $i . " :</label><br/";
    echo "<input name=\"req".$i."\" type=\"text\" /> <br />";
    $i++;
}

echo "<br />";
echo "<input name=\"submit\" type=\"submit\" />";

?>

Welcome to daniweb. I would suggest placing the value in a hidden field where when the next field is submitted it will then again be added to the $_POST array. So the following is an example:

<?php
$req = $_POST['req'];

echo '<form>';
for ($i=1; $i <= $req; $i++) {
echo '<label>Requirement ' . $i . ' :</label><br/>';
echo '<input name="req'.$i.'" type="text" /> <br />';
}
echo '<br /><input name="submit" type="submit" />';
echo '<input type="hidden" name="req" value="'.$_POST['req'].'"></form>';
?>

Second page

$req=$_GET['req'];

I also fixed a html bug in your code and changed the loop to make it run faster. And please use code tags.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.