Martien van Wanrooij wrote:
What I still didn't succeed to is the following: let us say the customer is
filling out the question5.php form but suddenly realises he made a mistake
in question2.php and wants to navigate back. Up to now I didn't succeed to
enable the customer to change the value in question2.php , when it has been
set once.
I already got the suggestion that rather than
//session_register("someVariable");
I should do something like
$session_id = session_id();
if(isset($someVariable)) {
$_SESSION['someVariable'] = $someVariable;
}
else {
$someVariable = $_SESSION['someVariable'];
}
Just start the session and use
$_SESSION['variable']
as another variable that keeps its value between pages.
Imagine
$_SESSION['variable']
is just a "funny" name for
$SESSION_variable
and use it whenever you need.
Ok, you have to save the information between all the pages. I use
session variables for that. The POST data is put in a session variable,
which is waht is used to display back to the user.
#v+
<?php // text1.php
session_start();
// avoid notices when going forward
$text1 = (isset($_SESSION['text1'])) ? $_SESSION['text1'] : '';
echo <<<HTML
<head><title>text1</title></head><body>
<form method="post" action="text2.php">
text1: <input type="text" name="text1" value="$text1"/><br/>
<input type="submit"/>
</form></body></html>
HTML;
?>
<?php // text2.php
session_start();
// save POST data in a session variable
$_SESSION['text1'] = (isset($_POST['text1'])) ? $_POST['text1'] : '';
// if there already is text2 data in session use it
$text2 = (isset($_SESSION['text2'])) ? $_SESSION['text2'] : '';
echo <<<HTML
<head><title>text2</title></head><body>
<form method="post" action="text3.php">
text2: <input type="text" name="text2" value="$text2"/><br/>
<input type="submit"/>
</form><p>Return to <a href="text1.php">text1</a>.</p>
</body></html>
HTML;
?>
<?php // text3.php
session_start();
// save POST data
$_SESSION['text2'] = (isset($_POST['text2'])) ? $_POST['text2'] : '';
$text3 = (isset($_SESSION['text3'])) ? $_SESSION['text3'] : '';
echo <<<HTML
<head><title>text3</title></head><body>
<form method="post" action="text4.php">
text3: <input type="text" name="text3" value="$text3"/><br/>
<input type="submit"/>
</form><p>Return to <a href="text1.php">text1</a> or <a
href="text2.php">text2</a>.</p>
</body></html>
HTML;
?>
<?php // text4.php
session_start();
// save POST data
$_SESSION['text3'] = (isset($_POST['text3'])) ? $_POST['text3'] : '';
echo <<<HTML
<head><title>text4</title></head><body>
<p>You entered:<br/>
text1: {$_SESSION['text1']}<br/>
text2: {$_SESSION['text2']}<br/>
text3: {$_SESSION['text3']}<br/>
</p>
<p>Return to <a href="text1.php">text1</a> or
<a href="text2.php">text2</a> or
<a href="text3.php">text3</a>.</p>
</body></html>
HTML;
?>
#v-
Happy Coding :-)
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--