I'm still working on sessions.
Here my page1:
<?php
session_start();
echo "<form name=\"aaaa\" method=\"post\" action=\"sessions_select_page2.php\">";
?>
<?php
function select( $selection , $values )
{
echo "<select name=\"$selection\">\n";
foreach( $values AS $val ) {
if ( isset( $_SESSION["$selection"] ) AND $_SESSION["$selection"] == $val )
$selected = " selected=\"selected\"";
else
$selected = "";
echo "\t<option value=\"$val\"$selected>$val</option>\n";
}
print "</select>\n";
}
echo 'Please choose item 1:'; select( "selection1" , array( "0", "6", "12", "18" ) );
echo 'Please choose item 2: '; select( "selection2" , array( "0", "6", "12", "18" ) );
?>
Is the value of the selected item equal to 0 (zero), there should not be the print out on page 2 . There should be a print out only for values bigger then 0 (zero). How to construct this "if else " function?
Here page 2:
<?php
session_start();
$_SESSION['selection1'] = $_POST['selection1'];
$_SESSION['selection2'] = $_POST['selection2'];
?>
<?php
$selection1 = $_POST['selection1'];
$selection2 = $_POST['selection2'];
print"You choose: $selection1 item1<br/>";
print"You choose: $selection2 item2";
?>
<p>
<input type="submit" name="submit" value=" confirm" onClick="location.href='sessions_select_page3.php'">
</p>
Thanks for your help.
See here for this example.