Foreword: (edit)
I noticed you've asked a few questions since first joining Stack but have not accepted any.
If there is a reason as to why you haven't accepted any, probably because none of the answers given solved an issue, do inform the person or persons to elaborate on their answer.
Answer:
Here, this is what you need to do, in regards to your comment about it "not working": (plus, you weren't assigning a variable in regards to your POST form element). This has already been explained.
Your (new) form: - Make sure there is nothing above this (no space, cookie, HTML, nothing), because it will cause/throw a "Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at...
" error; if error reporting is ON by default.
<?php
session_start();
// check if session is set, which will echo the last entered number
if(isset($_SESSION['views'])){
echo $_SESSION['views'];
}
?>
<form action="k1levelselect.php" method="post">
How many lessons do you want to create?
<input type="text" name="number" value=""><br>
<input type="submit" value="Submit">
</form>
Copy this into your k1levelselect.php file: - Make sure there is nothing above this (no space, cookie, HTML, nothing), because it will cause/throw a "Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at...
" error; if error reporting is ON by default.
<?php
session_start();
$number = $_POST['number']; // assign variable from POST
$_SESSION['views']=$number; // assign session to variable
$noOfLesson = $_SESSION['views'];
for($i = 1; $i <= $noOfLesson; $i++) {
echo "Pageviews=". $_SESSION['views'];
echo "<div>
<a href=\"k1levelX.php?lesson=".$i."\"><span>Lesson ".$i."</span></a>
</div>
<br>";
}
?>
If error reporting is not ON by default, add the following below your opening <?php
tags:
error_reporting(E_ALL);
ini_set('display_errors', 1);
It will show you any errors; if any.