I have a problem want to be solved.
I have three pages. page1.php, page2.php
page1.php has a form with two text field. one text field is for name and another is for number. there is a submit button and a "next" button too. using session I want show given name into page2.php and create checkboxes that according to given number. (e.g if I write 4 in number text field in page1.php then 4 checkboxes will appear in page2.php, if 8 then 8 checkboxes.
I want solve this problem using session.
page1.php
<body>
<p>
<?php
session_start();
?>
</p>
<form id="form1" name="form1" method="post" action="">
<p>
<label for="name">Name</label>
<input type="text" name="name" id="name" />
</p>
<p>
<label for="number">Number</label>
<input type="text" name="number" id="number" />
</p>
<p>
<input type="submit" name="submit" id="submit" value="SEND" />
</p> <br/>
<a href="page2.php"> next </a>
</form>
<?php
if(isset($_POST['submit']))
{
$_SESSION['Name'] = $_POST['name'];
$_SESSION['Number'] = $_POST['number'];
}
$nname = $_SESSION['Name'];
$nnumber = $_SESSION['Number'];
echo $nname . $nnumber;
?>
</body>
page2.php
<body>
<p>
<?php
session_start();
echo $_SESSION['Number'] . $_SESSION['Name'];
$nName = $_SESSION['Name'];
$nNumber = $_SESSION['Number'];
?>
</p>
<form name="form1" method="post" action="">
<input type="text" name="first_name" value="<?php echo $nName; ?>" />
<input type="checkbox" name="<?php for($i=0; $i< $nNumber; $i++)
echo $i;
?>" value="<?php for($i=0; $i< $nNumber; $i++)
echo $i;
?>" />
</form>
<p> <br/>
<a href="page1.php">Back</a></p>
</body>