Dear Djjjozsi
nice learning with your help. You open me up to the world of $_session that I've never heard about.
First of all I change the order form:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<p>
<form action="order.php" method="POST">
<input type="text" name="quantity1" value="0" onfocus="if(this.value=='0')this.value=''" size="5" />
item1
</p>
<p>
<input type="text" name="quantity2" value="0" onfocus="if(this.value=='0')this.value=''" size="5" />
item2
</p>
<p>
<input type="text" name="quantity3" value="0" onfocus="if(this.value=='0')this.value=''" size="5" />
item3</p>
<input type="submit" name="submit" value="order" />
</form>
</body>
</html>
Then I tried to insert the session variables:
<?php
session_start();
$_SESSION['quantity1'] = $_POST['quantity1'];
$_SESSION['quantity2'] = $_POST['quantity2'];
$_SESSION['quantity3'] = $_POST['quantity3'];
?>
<?php
$quantity1 = $_POST['quantity1'];
$quantity2 = $_POST['quantity2'];
$quantity3 = $_POST['quantity3'];
if ($_POST['quantity1'] != 0) {
print "you ordered $quantity1 item1 <br />";
}
if ($_POST['quantity2'] != 0) {
print "you ordered $quantity2 item2 <br />";
}
if ($_POST['quantity3'] != 0) {
print "you ordered $quantity3 item3 <br />";
}
?>
<input type="submit" name="submit" value=" I confirm my order" onClick="location.href='confirm.php'">
<a href="order_form.html"></a>
<input type="submit" name="submit" value=" I change my order" onClick="location.href='order_form.html'">
On the next script (confirm.php) the variables ( quantity1,quantity2, quantity3) are not passed. Just for an example I use the print function to check if the variables are available.
<?php
session_start();
$_SESSION['q1'] = $_POST['quantity1'];
$_SESSION["q2"] = $_POST['quantity2'];
$_SESSION["q3"] = $_POST['quantity3'];
?>
<?php
print "$quantity1 item1.";
print "$quantity2 item2.";
print "$quantity3 item3.";
print "Thanks."
?>
Where is the mistake?
Thanks for your suggestions.