Jump to content

PHP ordering form help please. variables staying the same after submit


timmykins02

Recommended Posts

So I'm making an ordering form for pizza, and it works fine and im using two separate pages: 1- display the form where the user can select the pizza, and 2-display the order and the price, and user can go back and edit

 

the problem im having is when i got back from the 2nd page to the 1st page, to edit the data, I want the variables to stay the same.  For example, if the user selected a medium cheese pizza, i want the values of cheese and pizza to still be there, so the user doesnt have to fill the entire form out again.

 

ive done this before, but now when i try it doesn''t work and Ive tried everything.  Thanks in advance

 

If the code is needed, I'll post it here

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Title of the document</title>
<meta name="description" content="Type a Short Description Here" />
<meta name="keywords" content="type, keywords, here" />
<meta name="author" content="Your Name" />
<meta http-equiv="content-type" content="text/html;charset=UTF-8" /> 
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>

<body>
<?php

print_r ($_REQUEST) ;

if(isset($_POST['ORDER'])) {
$ORDER = $_POST['ORDER'];
}
if(isset($_POST['PTYPE'])) {
$PTYPE = $_POST['PTYPE'];
}
if(isset($_POST['DTYPE'])) {
$DTYPE = $_POST['DTYPE'];
}
if(isset($_POST['PSIZE'])) {
$PSIZE = $_POST['PSIZE'];
}
if(isset($_POST['DSIZE'])) {
$DSIZE = $_POST['DSIZE'];
}
if(isset($_POST['PTYPE2'])) {
$PTYPE2 = $_POST['PTYPE2'];
}
if(isset($_POST['DTYPE2'])) {
$DTYPE2 = $_POST['DTYPE2'];
}
if(isset($_POST['PSIZE2'])) {
$PSIZE2 = $_POST['PSIZE2'];
}
if(isset($_POST['DSIZE2'])) {
$DSIZE2 = $_POST['DSIZE2'];
}
if(isset($_POST['PTYPE3'])) {
$PTYPE3 = $_POST['PTYPE3'];
}
if(isset($_POST['DTYPE3'])) {
$DTYPE3 = $_POST['DTYPE3'];
}
if(isset($_POST['PSIZE3'])) {
$PSIZE3 = $_POST['PSIZE3'];
}
if(isset($_POST['DSIZE3'])) {
$DSIZE3 = $_POST['DSIZE3'];
}


echo "Order Type: <br/> \n";
echo"<form method='post' action='project2.php'>";


}if ($ORDER=='delivery') {
$DEL='checked' ;
}elseif ($ORDER=='takeout') {
$TAKE='checked';
}elseif ($ORDER=='eatin') {
$EAT='checked';
}


echo"Delivery <input type='radio' name='ORDER' value='delivery' $DEL> \n";
echo"Take Out <input type='radio' name='ORDER' value='takeout' $TAKE> \n";
echo"Eat in <input type='radio' name='ORDER' value='eatin' $EAT> \n";

if ($PTYPE==='no pizza') {
$NOPIZZA='selected' ;
}elseif ($PTYPE=='cheese') {
$CHEESE='selected' ;
}elseif ($PTYPE=='pepporoni') {
$PEPPORONI='selected' ;
}elseif ($PTYPE=='veggie') {
$VEGGIE='selected' ;
}elseif ($PTYPE=='meat lovers') {
$MEAT='selected' ;
}

echo $CHEESE ;

echo"<br/>Pizza: <select name='PTYPE'>\n";
echo"<option></option>";
echo"<option $NOPIZZA>no pizza</option>";
echo"<option $CHEESE>cheese</option>";
echo"<option $PEPPORONI>pepporoni</option>";
echo"<option $VEGGIE>veggie</option>";
echo"<option $MEAT>meat lovers</option>";
echo"</select> ";

$SMALL='selected' ;


if (isset ($_POST['PSIZE']) && ($PSIZE=='Small')) {
$SMALL='selected' ;
}elseif (isset ($_POST['PSIZE']) && ($PSIZE=='Medium')) {
$MEDIUM='selected' ;
}elseif (isset ($_POST['PSIZE']) && ($PSIZE=='Large')) {
$LARGE='selected' ;
}

echo "$SMALL";

echo"    Pizza size: <select name='PSIZE'>\n";
echo"<option></option>";
echo"<option $SMALL>Small</option>";
echo"<option $MEDIUM>Medium</option>";
echo"<option $LARGE>Large</option>";
echo"</select>";

echo"<br/>Pizza2: <select name='PTYPE2'>\n";
echo"<option></option>";
echo"<option >no pizza</option>";
echo"<option >cheese</option>";
echo"<option >pepporoni</option>";
echo"<option >veggie</option>";
echo"<option >meat lovers</option>";
echo"</select> ";

echo"    Pizza size2: <select name='PSIZE2'>\n";
echo"<option></option>";
echo"<option>Small</option>";
echo"<option>Medium</option>";
echo"<option>Large</option>";
echo"</select>";

echo"<br/>Pizza3: <select name='PTYPE3'>\n";
echo"<option></option>";
echo"<option >no pizza</option>";
echo"<option >cheese</option>";
echo"<option >pepporoni</option>";
echo"<option >veggie</option>";
echo"<option >meat lovers</option>";
echo"</select> ";

echo"Pizza size3: <select name='PSIZE3'>\n";
echo"<option></option>";
echo"<option>Small</option>";
echo"<option>Medium</option>";
echo"<option>Large</option>";
echo"</select>";

echo"</br> <br/>What drink would you like? <select name='DTYPE'>";
echo"<option></option>";
echo"<option>No drink</option>";
echo"<option>Bottled Pepsi</option>";
echo"<option>Bottled Fanta</option>";
echo"<option>Bottled Sprite</option>";
echo"<option>Bottled RootBeer</option>";
echo"</select>";

echo"Drink size: <select name='DSIZE'>";
echo"<option></option>";
echo"<option>.5 liter</option>";
echo"<option>1 liter</option>";
echo"<option>2 liter</option>";
echo"</select>";


echo"</br> <br/>What second drink would you like? <select name='DTYPE2'>";
echo"<option></option>";
echo"<option>No drink</option>";
echo"<option>Bottled Pepsi</option>";
echo"<option>Bottled Fanta</option>";
echo"<option>Bottled Sprite</option>";
echo"<option>Bottled RootBeer</option>";
echo"</select>";

echo"Drink size2: <select name='DSIZE2'>";
echo"<option></option>";
echo"<option>.5 liter</option>";
echo"<option>1 liter</option>";
echo"<option>2 liter</option>";
echo"</select>";


echo"</br> <br/>What third drink would you like? <select name='DTYPE3'>";
echo"<option></option>";
echo"<option>No drink</option>";
echo"<option>Bottled Pepsi</option>";
echo"<option>Bottled Fanta</option>";
echo"<option>Bottled Sprite</option>";
echo"<option>Bottled RootBeer</option>";
echo"</select>";

echo"Drink size3: <select name='DSIZE3'>";
echo"<option></option>";
echo"<option>.5 liter</option>";
echo"<option>1 liter</option>";
echo"<option>2 liter</option>";
echo"</select>";






echo"<br/> <br/> <input type='submit' value='submit your order' name='submit'>";
echo"</form>";


?>
</body>
</html>

 

and the second page

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Title of the document</title>
<meta name="description" content="Type a Short Description Here" />
<meta name="keywords" content="type, keywords, here" />
<meta name="author" content="Your Name" />
<meta http-equiv="content-type" content="text/html;charset=UTF-8" /> 
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>

<body>
<?php

print_r ($_REQUEST) ;

$ORDER = $_POST['ORDER'];
$PTYPE = $_POST['PTYPE'];
$DTYPE = $_POST['DTYPE'];
$PSIZE = $_POST['PSIZE'];
$DSIZE = $_POST['DSIZE'];
$PTYPE2 = $_POST['PTYPE2'];
$DTYPE2 = $_POST['DTYPE2'];
$PSIZE2 = $_POST['PSIZE2'];
$DSIZE2 = $_POST['DSIZE2'];
$PTYPE3 = $_POST['PTYPE3'];
$DTYPE3 = $_POST['DTYPE3'];
$PSIZE3 = $_POST['PSIZE3'];
$DSIZE3 = $_POST['DSIZE3'];




if (($PTYPE=='cheese')and($PSIZE=='Small')) {
$PCOST=10 ;
}elseif (($PTYPE=='cheese')and($PSIZE=='Medium')) {
$PCOST=13 ;
}elseif (($PTYPE=='cheese')and($PSIZE=='Large')) {
$PCOST=15 ;
}elseif (($PTYPE=='pepporoni')and($PSIZE=='Small')) {
$PCOST=12 ;
}elseif (($PTYPE=='pepporoni')and($PSIZE=='Medium')) {
$PCOST=14 ;
}elseif (($PTYPE=='pepporoni')and($PSIZE=='Large')) {
$PCOST=16 ;
}elseif (($PTYPE=='veggie')and($PSIZE=='Small')) {
$PCOST=12 ;
}elseif (($PTYPE=='veggie')and($PSIZE=='Medium')) {
$PCOST=14 ;
}elseif (($PTYPE=='veggie')and($PSIZE=='Large')) {
$PCOST=16 ;
}elseif (($PTYPE=='meat lovers')and($PSIZE=='Small')) {
$PCOST=13 ;
}elseif (($PTYPE=='meat lovers')and($PSIZE=='Medium')) {
$PCOST=15 ;
}elseif (($PTYPE=='meat lovers')and($PSIZE=='Large')) {
$PCOST=17;
}else {
$PCOST=0 ;
}


if (($PTYPE2=='cheese')and($PSIZE2=='Small')) {
$PCOST2=10 ;
}elseif (($PTYPE2=='cheese')and($PSIZE2=='Medium')) {
$PCOST2=13 ;
}elseif (($PTYPE2=='cheese')and($PSIZE2=='Large')) {
$PCOST2=15 ;
}elseif (($PTYPE2=='pepporoni')and($PSIZE2=='Small')) {
$PCOST2=12 ;
}elseif (($PTYPE2=='pepporoni')and($PSIZE2=='Medium')) {
$PCOST2=14 ;
}elseif (($PTYPE2=='pepporoni')and($PSIZE2=='Large')) {
$PCOST2=16 ;
}elseif (($PTYPE2=='veggie')and($PSIZE2=='Small')) {
$PCOST2=12 ;
}elseif (($PTYPE2=='veggie')and($PSIZE2=='Medium')) {
$PCOST2=14 ;
}elseif (($PTYPE2=='veggie')and($PSIZE2=='Large')) {
$PCOST2=16 ;
}elseif (($PTYPE2=='meat lovers')and($PSIZE2=='Small')) {
$PCOST2=13 ;
}elseif (($PTYPE2=='meat lovers')and($PSIZE2=='Medium')) {
$PCOST2=15 ;
}elseif (($PTYPE2=='meat lovers')and($PSIZE2=='Large')) {
$PCOST2=17;
}else {
$PCOST2=0 ;
}


if (($PTYPE3=='cheese')and($PSIZE3=='Small')) {
$PCOST3=10 ;
}elseif (($PTYPE3=='cheese')and($PSIZE3=='Medium')) {
$PCOST3=13 ;
}elseif (($PTYPE3=='cheese')and($PSIZE3=='Large')) {
$PCOST3=15 ;
}elseif (($PTYPE3=='pepporoni')and($PSIZE3=='Small')) {
$PCOST3=12 ;
}elseif (($PTYPE3=='pepporoni')and($PSIZE3=='Medium')) {
$PCOST3=14 ;
}elseif (($PTYPE3=='pepporoni')and($PSIZE3=='Large')) {
$PCOST3=16 ;
}elseif (($PTYPE3=='veggie')and($PSIZE3=='Small')) {
$PCOST3=12 ;
}elseif (($PTYPE3=='veggie')and($PSIZE3=='Medium')) {
$PCOST3=14 ;
}elseif (($PTYPE3=='veggie')and($PSIZE3=='Large')) {
$PCOST3=16 ;
}elseif (($PTYPE3=='meat lovers')and($PSIZE3=='Small')) {
$PCOST3=13 ;
}elseif (($PTYPE3=='meat lovers')and($PSIZE3=='Medium')) {
$PCOST3=15 ;
}elseif (($PTYPE3=='meat lovers')and($PSIZE3=='Large')) {
$PCOST3=17;
}else {
$PCOST3=0 ;
}

if((($DTYPE=='Bottled Pepsi')or($DTYPE=='Bottled Fanta')or($DTYPE=='Bottled Sprite')or($DTYPE=='Bottled RootBeer'))and($DSIZE=='.5 liter')) {
$DCOST=.69 ;
}elseif((($DTYPE=='Bottled Pepsi')or($DTYPE=='Bottled Fanta')or($DTYPE=='Bottled Sprite')or($DTYPE=='Bottled RootBeer'))and($DSIZE=='1 liter')) {
$DCOST=.99 ;
}elseif((($DTYPE=='Bottled Pepsi')or($DTYPE=='Bottled Fanta')or($DTYPE=='Bottled Sprite')or($DTYPE=='Bottled RootBeer'))and($DSIZE=='2 liter')) {
$DCOST=1.69 ;
}elseif($DTYPE=='No drink'){
$DCOST=0 ;
}

if((($DTYPE2=='Bottled Pepsi')or($DTYPE2=='Bottled Fanta')or($DTYPE2=='Bottled Sprite')or($DTYPE2=='Bottled RootBeer'))and($DSIZE2=='.5 liter')) {
$DCOST2=.69 ;
}elseif((($DTYPE2=='Bottled Pepsi')or($DTYPE2=='Bottled Fanta')or($DTYPE2=='Bottled Sprite')or($DTYPE2=='Bottled RootBeer'))and($DSIZE2=='1 liter')) {
$DCOST2=.99 ;
}elseif((($DTYPE2=='Bottled Pepsi')or($DTYPE2=='Bottled Fanta')or($DTYPE2=='Bottled Sprite')or($DTYPE2=='Bottled RootBeer'))and($DSIZE2=='2 liter')) {
$DCOST2=1.69 ;
}elseif($DTYPE2=='No drink'){
$DCOST2=0 ;
}

if((($DTYPE3=='Bottled Pepsi')or($DTYPE3=='Bottled Fanta')or($DTYPE3=='Bottled Sprite')or($DTYPE3=='Bottled RootBeer'))and($DSIZE3=='.5 liter')) {
$DCOST3=.69 ;
}elseif((($DTYPE3=='Bottled Pepsi')or($DTYPE3=='Bottled Fanta')or($DTYPE3=='Bottled Sprite')or($DTYPE3=='Bottled RootBeer'))and($DSIZE3=='1 liter')) {
$DCOST3=.99 ;
}elseif((($DTYPE3=='Bottled Pepsi')or($DTYPE3=='Bottled Fanta')or($DTYPE3=='Bottled Sprite')or($DTYPE3=='Bottled RootBeer'))and($DSIZE3=='2 liter')) {
$DCOST3=1.69 ;
}elseif($DTYPE3=='No drink'){
$DCOST3=0 ;
}

$TOTAL=($PCOST+$PCOST3+$PCOST3+$DCOST+$DCOST2+$DCOST3) ;

echo "<br/><br/>Your Order is:<br/>" ;
echo " $PSIZE $PTYPE ($PCOST),$PSIZE2 $PTYPE2 ($PCOST2),$PSIZE3 $PTYPE3 ($PCOST3),  <br/>" ;
echo " $DSIZE $DTYPE ($DCOST),$DSIZE2 $DTYPE2 ($DCOST2),$DSIZE3 $DTYPE3 ($DCOST3), <br/> <br/>" ;
echo"<br/><br/>Your total price is: $TOTAL <br/> <br/>";






if ($ORDER=='delivery') {
echo"Please enter the information required for delivery <br/>" ;
echo "Address: <input type=text><br/>";
echo "City: <input type=text><br/>";
echo "Zip Code: <input type=text><br/>";
} elseif ($ORDER=='takeout') {
echo "Your order will be ready for pickup in 30 min";
} elseif ($ORDER=='eatin') {
echo "Your order will be ready in 30 min";
}

echo"<form action=asdf.php>";
echo"<br/> <input type=submit value='confirm this order'>"; 
echo"</form>";










echo "<form action=project.php>";
echo "<br/> <br/><input type=submit value='edit this order'>";
echo "<input type='hidden' name='ORDER' value='$ORDER'>";
echo "<input type='hidden' name='PTYPE' value='$PTYPE'>";
echo "<input type='hidden' name='PTYPE2' value='$PTYPE2'>";
echo "<input type='hidden' name='PTYPE3' value='$PTYPE3'>";
echo "<input type='hidden' name='PSIZE' value='$PSIZE'>";
echo "<input type='hidden' name='PSIZE2' value='$PSIZE2'>";
echo "<input type='hidden' name='PSIZE3' value='$PSIZE3'>";
echo "<input type='hidden' name='DTYPE' value='$DTYPE'>";
echo "<input type='hidden' name='DTYPE2' value='$DTYPE2'>";
echo "<input type='hidden' name='DTYPE3' value='$DTYPE3'>";
echo "<input type='hidden' name='DSIZE' value='$DSIZE'>";
echo "<input type='hidden' name='DSIZE2' value='$DSIZE2'>";
echo "<input type='hidden' name='DSIZE3' value='$DSIZE3'>";
echo "</form>";



?>
</body>
</html>

 

Link to comment
Share on other sites

Hello Timmy,

 

I would recommend the use of sessions.  Use session_start() on both pages.  When the user submits the first page, on page 2, you should register the user inputs.

 

For example: on page 2 should be something like this:

 

<?php 

session_start();
$_SESSION['ORDER'] = $_POST['ORDER'];
$_SESSION['PTYPE'] = $_POST['PTYPE'];
$_SESSION['DTYPE'] = $_POST['DTYPE'];
$_SESSION['PSIZE'] = $_POST['PSIZE'];
$_SESSION['DSIZE'] = $_POST['DSIZE'];
$_SESSION['PTYPE2'] = $_POST['PTYPE2'];
$_SESSION['DTYPE2'] = $_POST['DTYPE2'];
$_SESSION['PSIZE2'] = $_POST['PSIZE2'];
$_SESSION['DSIZE2'] = $_POST['DSIZE2'];
$_SESSION['PTYPE3'] = $_POST['PTYPE3'];
$_SESSION['DTYPE3'] = $_POST['DTYPE3'];
$_SESSION['PSIZE3'] = $_POST['PSIZE3'];
$_SESSION['DSIZE3'] = $_POST['DSIZE3'];
// And etc... for all those user inputs.  

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Title of the document</title>
<meta name="description" content="Type a Short Description Here" />
<meta name="keywords" content="type, keywords, here" />
<meta name="author" content="Your Name" />
<meta http-equiv="content-type" content="text/html;charset=UTF-8" /> 
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>
... etc....

 

 

Then on your first page, you would have something like this:

 

<?php 
if(isset($_SESSION['PTYPE'])){
if ($_SESSION['PTYPE'] == 'no pizza') {
$NOPIZZA='selected' ;
}elseif ($_SESSION['PTYPE'] == 'cheese') {
$CHEESE='selected' ;
}elseif ($_SESSION['PTYPE'] =='pepporoni') {
$PEPPORONI='selected' ;
}elseif ($_SESSION['PTYPE']=='veggie') {
$VEGGIE='selected' ;
}elseif ($_SESSION['PTYPE'] =='meat lovers') {
$MEAT='selected' ;
}
}
echo"<br/>Pizza: <select name='PTYPE'>\n";
echo"<option></option>";
echo"<option $NOPIZZA>no pizza</option>";
echo"<option $CHEESE>cheese</option>";
echo"<option $PEPPORONI>pepporoni</option>";
echo"<option $VEGGIE>veggie</option>";
echo"<option $MEAT>meat lovers</option>";
echo"</select> ";

 

That's just an overview of what can be done.

Link to comment
Share on other sites

You can make a copy of the entire $_POST array using one statement -

 

$_SESSION['post_data'] = $_POST;

 

You would reference each value like - $_SESSION['post_data']['ORDER'] or you can simply copy the values from the session variable back to the $_POST array - $_POST = $_SESSION['post_data'];

Link to comment
Share on other sites

It can also be done that way, then extract all the post variables:

 

On second page would be:

 

$_SESSION['post_data'] = $_POST;

 

On first page you can extract:

 

if(isset($_SESSION['post_data'])) {extract($_SESSION['post_data'];}

 

And then refer to all the variables directly;  $PTYPE, $ORDER etc..

 

Link to comment
Share on other sites

If you're going to use sessions to transfer form data around, you should group it in such a way that the data is unique to that form, and that series of requests.

 

Sessions will propagate over multiple tabs/windows. If someone visits the same or a similar form in another tab that uses $_SESSION['post_data'], the data from the original form may get changed.

Link to comment
Share on other sites

I tried this but still doesnt work. It keeps on saying

 

Notice: Undefined variable: DEL in C:\Program Files\EasyPHP-5.3.6.1\www\Project\project.php on line 77

Notice: Undefined variable: TAKE in C:\Program Files\EasyPHP-5.3.6.1\www\Project\project.php on line 78

Notice: Undefined variable: EAT in C:\Program Files\EasyPHP-5.3.6.1\www\Project\project.php on line 79

Notice: Undefined variable: CHEESE in C:\Program Files\EasyPHP-5.3.6.1\www\Project\project.php on line 95

 

and i used print_r ($REQUEST) to see all of the variables and they are all kept when I go from page 2 to the first page, and with the use of my IF statement, $DEL should become selected, but it doesnt, and the variable is said to be undefined.  Im new to php and i dont understand why it isnt working, ive done it before this way.  Please help me.  the part of the code is

if(isset($_SESSION['ORDER'])){
if ($_SESSION['ORDER'] == 'delivery') {
$DEL='selected' ;
}elseif ($_SESSION['ORDER'] == 'takeout') {
$TAKE='selected' ;
}elseif ($_SESSION['ORDER'] =='eatin') {
$EAT='selected' ;
}
}



echo"Delivery <input type='radio' name='ORDER' value='delivery' $DEL> \n";
echo"Take Out <input type='radio' name='ORDER' value='takeout' $TAKE> \n";
echo"Eat in <input type='radio' name='ORDER' value='eatin' $EAT> \n";

Link to comment
Share on other sites

Need to make sure they are set:

<?php 
echo"Delivery <input type='radio' name='ORDER' value='delivery' <?php if(isset($DEL)){echo $DEL;?>> \n";
echo"Take Out <input type='radio' name='ORDER' value='takeout' <?php if(isset($TAKE)){echo $TAKE;?>> \n";
echo"Eat in <input type='radio' name='ORDER' value='eatin' <?php if(isset($EAT)){echo $EAT;?>> \n";
?>

Link to comment
Share on other sites

Need to make sure they are set:

<?php 
echo"Delivery <input type='radio' name='ORDER' value='delivery' <?php if(isset($DEL)){echo $DEL;?>> \n";
echo"Take Out <input type='radio' name='ORDER' value='takeout' <?php if(isset($TAKE)){echo $TAKE;?>> \n";
echo"Eat in <input type='radio' name='ORDER' value='eatin' <?php if(isset($EAT)){echo $EAT;?>> \n";
?>

 

I tried that but i still get the notices of

Notice: Undefined variable: DEL in C:\Program Files\EasyPHP-5.3.6.1\www\Project\project.php on line 75

 

Notice: Undefined variable: TAKE in C:\Program Files\EasyPHP-5.3.6.1\www\Project\project.php on line 79

 

Notice: Undefined variable: EAT in C:\Program Files\EasyPHP-5.3.6.1\www\Project\project.php on line 83

Link to comment
Share on other sites

Can someone please help? This is very important and I need this done quickly. Sorry for being so needy. Can someone just look at my codes quickly and make a quick fix?

 

The problem is that when I go back to the first page, the variables dont say put. For example, if I checked "delivery" for the order type, it doesn't stay checked when I go back to that page.

 

Here are the codes. Code 1

<?php

print_r ($_REQUEST) ;

if(isset($_POST['ORDER'])) {
$ORDER = $_POST['ORDER'];
}
if(isset($_POST['PTYPE'])) {
$PTYPE = $_POST['PTYPE'];
}
if(isset($_POST['DTYPE'])) {
$DTYPE = $_POST['DTYPE'];
}
if(isset($_POST['PSIZE'])) {
$PSIZE = $_POST['PSIZE'];
}
if(isset($_POST['DSIZE'])) {
$DSIZE = $_POST['DSIZE'];
}
if(isset($_POST['PTYPE2'])) {
$PTYPE2 = $_POST['PTYPE2'];
}
if(isset($_POST['DTYPE2'])) {
$DTYPE2 = $_POST['DTYPE2'];
}
if(isset($_POST['PSIZE2'])) {
$PSIZE2 = $_POST['PSIZE2'];
}
if(isset($_POST['DSIZE2'])) {
$DSIZE2 = $_POST['DSIZE2'];
}
if(isset($_POST['PTYPE3'])) {
$PTYPE3 = $_POST['PTYPE3'];
}
if(isset($_POST['DTYPE3'])) {
$DTYPE3 = $_POST['DTYPE3'];
}
if(isset($_POST['PSIZE3'])) {
$PSIZE3 = $_POST['PSIZE3'];
}
if(isset($_POST['DSIZE3'])) {
$DSIZE3 = $_POST['DSIZE3'];
}



echo "Order Type: <br/> \n";
echo"<form method='post' action='project2.php'>";


if(isset($_SESSION['ORDER'])){
if ($_SESSION['ORDER'] == 'delivery') {
$DEL='selected' ;
}elseif ($_SESSION['ORDER'] == 'takeout') {
$TAKE='selected' ;
}elseif ($_SESSION['ORDER'] =='eatin') {
$EAT='selected' ;
}
}



echo"Delivery <input type='radio' name='ORDER' value='delivery' $DEL>"  ;
if(isset($DEL)){
echo $DEL;
}
echo"Take Out <input type='radio' name='ORDER' value='takeout' $TAKE>"   ;
if(isset($TAKE)){
echo $TAKE;  
} 
echo"Eat in <input type='radio' name='ORDER' value='eatin' $EAT>" ;
if(isset($EAT)){
echo $EAT;
}
if(isset($_SESSION['PTYPE'])){
if ($_SESSION['PTYPE'] == 'no pizza') {
$NOPIZZA='selected' ;
}elseif ($_SESSION['PTYPE'] == 'cheese') {
$CHEESE='selected' ;
}elseif ($_SESSION['PTYPE'] =='pepporoni') {
$PEPPORONI='selected' ;
}elseif ($_SESSION['PTYPE']=='veggie') {
$VEGGIE='selected' ;
}elseif ($_SESSION['PTYPE'] =='meat lovers') {
$MEAT='selected' ;
}
}

 

I know its really messy ive been trying a lot of diffferent things. 

 

code 2

<?php

print_r ($_REQUEST) ;

$_SESSION['post_data'] = $_POST;

session_start();
$_SESSION['ORDER'] = $_POST['ORDER'];
$_SESSION['PTYPE'] = $_POST['PTYPE'];
$_SESSION['DTYPE'] = $_POST['DTYPE'];
$_SESSION['PSIZE'] = $_POST['PSIZE'];
$_SESSION['DSIZE'] = $_POST['DSIZE'];
$_SESSION['PTYPE2'] = $_POST['PTYPE2'];
$_SESSION['DTYPE2'] = $_POST['DTYPE2'];
$_SESSION['PSIZE2'] = $_POST['PSIZE2'];
$_SESSION['DSIZE2'] = $_POST['DSIZE2'];
$_SESSION['PTYPE3'] = $_POST['PTYPE3'];
$_SESSION['DTYPE3'] = $_POST['DTYPE3'];
$_SESSION['PSIZE3'] = $_POST['PSIZE3'];
$_SESSION['DSIZE3'] = $_POST['DSIZE3'];



$ORDER = $_POST['ORDER'];
$PTYPE = $_POST['PTYPE'];
$DTYPE = $_POST['DTYPE'];
$PSIZE = $_POST['PSIZE'];
$DSIZE = $_POST['DSIZE'];
$PTYPE2 = $_POST['PTYPE2'];
$DTYPE2 = $_POST['DTYPE2'];
$PSIZE2 = $_POST['PSIZE2'];
$DSIZE2 = $_POST['DSIZE2'];
$PTYPE3 = $_POST['PTYPE3'];
$DTYPE3 = $_POST['DTYPE3'];
$PSIZE3 = $_POST['PSIZE3'];
$DSIZE3 = $_POST['DSIZE3'];




if (($PTYPE=='cheese')and($PSIZE=='Small')) {
$PCOST=10 ;
}elseif (($PTYPE=='cheese')and($PSIZE=='Medium')) {
$PCOST=13 ;
}elseif (($PTYPE=='cheese')and($PSIZE=='Large')) {
$PCOST=15 ;
}elseif (($PTYPE=='pepporoni')and($PSIZE=='Small')) {
$PCOST=12 ;
}elseif (($PTYPE=='pepporoni')and($PSIZE=='Medium')) {
$PCOST=14 ;
}elseif (($PTYPE=='pepporoni')and($PSIZE=='Large')) {
$PCOST=16 ;
}elseif (($PTYPE=='veggie')and($PSIZE=='Small')) {
$PCOST=12 ;
}elseif (($PTYPE=='veggie')and($PSIZE=='Medium')) {
$PCOST=14 ;
}elseif (($PTYPE=='veggie')and($PSIZE=='Large')) {
$PCOST=16 ;
}elseif (($PTYPE=='meat lovers')and($PSIZE=='Small')) {
$PCOST=13 ;
}elseif (($PTYPE=='meat lovers')and($PSIZE=='Medium')) {
$PCOST=15 ;
}elseif (($PTYPE=='meat lovers')and($PSIZE=='Large')) {
$PCOST=17;
}else {
$PCOST=0 ;
}


if (($PTYPE2=='cheese')and($PSIZE2=='Small')) {
$PCOST2=10 ;
}elseif (($PTYPE2=='cheese')and($PSIZE2=='Medium')) {
$PCOST2=13 ;
}elseif (($PTYPE2=='cheese')and($PSIZE2=='Large')) {
$PCOST2=15 ;
}elseif (($PTYPE2=='pepporoni')and($PSIZE2=='Small')) {
$PCOST2=12 ;
}elseif (($PTYPE2=='pepporoni')and($PSIZE2=='Medium')) {
$PCOST2=14 ;
}elseif (($PTYPE2=='pepporoni')and($PSIZE2=='Large')) {
$PCOST2=16 ;
}elseif (($PTYPE2=='veggie')and($PSIZE2=='Small')) {
$PCOST2=12 ;
}elseif (($PTYPE2=='veggie')and($PSIZE2=='Medium')) {
$PCOST2=14 ;
}elseif (($PTYPE2=='veggie')and($PSIZE2=='Large')) {
$PCOST2=16 ;
}elseif (($PTYPE2=='meat lovers')and($PSIZE2=='Small')) {
$PCOST2=13 ;
}elseif (($PTYPE2=='meat lovers')and($PSIZE2=='Medium')) {
$PCOST2=15 ;
}elseif (($PTYPE2=='meat lovers')and($PSIZE2=='Large')) {
$PCOST2=17;
}else {
$PCOST2=0 ;
}


if (($PTYPE3=='cheese')and($PSIZE3=='Small')) {
$PCOST3=10 ;
}elseif (($PTYPE3=='cheese')and($PSIZE3=='Medium')) {
$PCOST3=13 ;
}elseif (($PTYPE3=='cheese')and($PSIZE3=='Large')) {
$PCOST3=15 ;
}elseif (($PTYPE3=='pepporoni')and($PSIZE3=='Small')) {
$PCOST3=12 ;
}elseif (($PTYPE3=='pepporoni')and($PSIZE3=='Medium')) {
$PCOST3=14 ;
}elseif (($PTYPE3=='pepporoni')and($PSIZE3=='Large')) {
$PCOST3=16 ;
}elseif (($PTYPE3=='veggie')and($PSIZE3=='Small')) {
$PCOST3=12 ;
}elseif (($PTYPE3=='veggie')and($PSIZE3=='Medium')) {
$PCOST3=14 ;
}elseif (($PTYPE3=='veggie')and($PSIZE3=='Large')) {
$PCOST3=16 ;
}elseif (($PTYPE3=='meat lovers')and($PSIZE3=='Small')) {
$PCOST3=13 ;
}elseif (($PTYPE3=='meat lovers')and($PSIZE3=='Medium')) {
$PCOST3=15 ;
}elseif (($PTYPE3=='meat lovers')and($PSIZE3=='Large')) {
$PCOST3=17;
}else {
$PCOST3=0 ;
}

if((($DTYPE=='Bottled Pepsi')or($DTYPE=='Bottled Fanta')or($DTYPE=='Bottled Sprite')or($DTYPE=='Bottled RootBeer'))and($DSIZE=='.5 liter')) {
$DCOST=.69 ;
}elseif((($DTYPE=='Bottled Pepsi')or($DTYPE=='Bottled Fanta')or($DTYPE=='Bottled Sprite')or($DTYPE=='Bottled RootBeer'))and($DSIZE=='1 liter')) {
$DCOST=.99 ;
}elseif((($DTYPE=='Bottled Pepsi')or($DTYPE=='Bottled Fanta')or($DTYPE=='Bottled Sprite')or($DTYPE=='Bottled RootBeer'))and($DSIZE=='2 liter')) {
$DCOST=1.69 ;
}elseif($DTYPE=='No drink'){
$DCOST=0 ;
}

if((($DTYPE2=='Bottled Pepsi')or($DTYPE2=='Bottled Fanta')or($DTYPE2=='Bottled Sprite')or($DTYPE2=='Bottled RootBeer'))and($DSIZE2=='.5 liter')) {
$DCOST2=.69 ;
}elseif((($DTYPE2=='Bottled Pepsi')or($DTYPE2=='Bottled Fanta')or($DTYPE2=='Bottled Sprite')or($DTYPE2=='Bottled RootBeer'))and($DSIZE2=='1 liter')) {
$DCOST2=.99 ;
}elseif((($DTYPE2=='Bottled Pepsi')or($DTYPE2=='Bottled Fanta')or($DTYPE2=='Bottled Sprite')or($DTYPE2=='Bottled RootBeer'))and($DSIZE2=='2 liter')) {
$DCOST2=1.69 ;
}elseif($DTYPE2=='No drink'){
$DCOST2=0 ;
}

if((($DTYPE3=='Bottled Pepsi')or($DTYPE3=='Bottled Fanta')or($DTYPE3=='Bottled Sprite')or($DTYPE3=='Bottled RootBeer'))and($DSIZE3=='.5 liter')) {
$DCOST3=.69 ;
}elseif((($DTYPE3=='Bottled Pepsi')or($DTYPE3=='Bottled Fanta')or($DTYPE3=='Bottled Sprite')or($DTYPE3=='Bottled RootBeer'))and($DSIZE3=='1 liter')) {
$DCOST3=.99 ;
}elseif((($DTYPE3=='Bottled Pepsi')or($DTYPE3=='Bottled Fanta')or($DTYPE3=='Bottled Sprite')or($DTYPE3=='Bottled RootBeer'))and($DSIZE3=='2 liter')) {
$DCOST3=1.69 ;
}elseif($DTYPE3=='No drink'){
$DCOST3=0 ;
}

$TOTAL=($PCOST+$PCOST3+$PCOST3+$DCOST+$DCOST2+$DCOST3) ;

echo "<br/><br/>Your Order is:<br/>" ;
echo " $PSIZE $PTYPE ($PCOST),$PSIZE2 $PTYPE2 ($PCOST2),$PSIZE3 $PTYPE3 ($PCOST3),  <br/>" ;
echo " $DSIZE $DTYPE ($DCOST),$DSIZE2 $DTYPE2 ($DCOST2),$DSIZE3 $DTYPE3 ($DCOST3), <br/> <br/>" ;
echo"<br/><br/>Your total price is: $TOTAL <br/> <br/>";






if ($ORDER=='delivery') {
echo"Please enter the information required for delivery <br/>" ;
echo "Address: <input type=text><br/>";
echo "City: <input type=text><br/>";
echo "Zip Code: <input type=text><br/>";
} elseif ($ORDER=='takeout') {
echo "Your order will be ready for pickup in 30 min";
} elseif ($ORDER=='eatin') {
echo "Your order will be ready in 30 min";
}

echo"<form action=asdf.php>";
echo"<br/> <input type=submit value='confirm this order'>"; 
echo"</form>";










echo "<form action=project.php>";
echo "<br/> <br/><input type=submit value='edit this order'>";
echo "<input type='hidden' name='ORDER' value='$ORDER'>";
echo "<input type='hidden' name='PTYPE' value='$PTYPE'>";
echo "<input type='hidden' name='PTYPE2' value='$PTYPE2'>";
echo "<input type='hidden' name='PTYPE3' value='$PTYPE3'>";
echo "<input type='hidden' name='PSIZE' value='$PSIZE'>";
echo "<input type='hidden' name='PSIZE2' value='$PSIZE2'>";
echo "<input type='hidden' name='PSIZE3' value='$PSIZE3'>";
echo "<input type='hidden' name='DTYPE' value='$DTYPE'>";
echo "<input type='hidden' name='DTYPE2' value='$DTYPE2'>";
echo "<input type='hidden' name='DTYPE3' value='$DTYPE3'>";
echo "<input type='hidden' name='DSIZE' value='$DSIZE'>";
echo "<input type='hidden' name='DSIZE2' value='$DSIZE2'>";
echo "<input type='hidden' name='DSIZE3' value='$DSIZE3'>";
echo "</form>";



?>

Link to comment
Share on other sites

I'll let you do the other one.

<?php
session_start();  //start session;
$_SESSION['post_data'] = $_POST; //store all post data to the session array.
print_r ($_REQUEST) ;

/*if(isset($_POST['ORDER'])) {
$ORDER = $_POST['ORDER'];
}
if(isset($_POST['PTYPE'])) {
$PTYPE = $_POST['PTYPE'];
}
if(isset($_POST['DTYPE'])) {
$DTYPE = $_POST['DTYPE'];
}
if(isset($_POST['PSIZE'])) {
$PSIZE = $_POST['PSIZE'];
}
if(isset($_POST['DSIZE'])) {
$DSIZE = $_POST['DSIZE'];
}
if(isset($_POST['PTYPE2'])) {
$PTYPE2 = $_POST['PTYPE2'];
}
if(isset($_POST['DTYPE2'])) {
$DTYPE2 = $_POST['DTYPE2'];
}
if(isset($_POST['PSIZE2'])) {
$PSIZE2 = $_POST['PSIZE2'];
}
if(isset($_POST['DSIZE2'])) {
$DSIZE2 = $_POST['DSIZE2'];
}
if(isset($_POST['PTYPE3'])) {
$PTYPE3 = $_POST['PTYPE3'];
}
if(isset($_POST['DTYPE3'])) {
$DTYPE3 = $_POST['DTYPE3'];
}
if(isset($_POST['PSIZE3'])) {
$PSIZE3 = $_POST['PSIZE3'];
}
if(isset($_POST['DSIZE3'])) {
$DSIZE3 = $_POST['DSIZE3'];
}
*/


echo "Order Type: <br/> \n";
echo"<form method='post' action='project2.php'>";
//set the variables.
$DEL = NULL;
$TAKE = NULL;
$EAT = NULL;

if(isset($_SESSION['post_data']['ORDER'])){
if ($_SESSION['post_data']['ORDER'] == 'delivery') {
$DEL='selected' ;
}elseif ($_SESSION['post_data']['ORDER'] == 'takeout') {
$TAKE='selected' ;
}elseif ($_SESSION['post_data']['ORDER'] =='eatin') {
$EAT='selected' ;
}
}



echo"Delivery <input type='radio' name='ORDER' value='delivery' $DEL>"  ;
if(isset($DEL)){
echo $DEL;
}
echo"Take Out <input type='radio' name='ORDER' value='takeout' $TAKE>"   ;
if(isset($TAKE)){
echo $TAKE;  
} 
echo"Eat in <input type='radio' name='ORDER' value='eatin' $EAT>" ;
if(isset($EAT)){
echo $EAT;
}
//set the variables.
$NOPIZZA = NULL;
$CHEESE = NULL;
$PEPPORONI = NULL;
$VEGGIE = NULL;
$MEAT = NULL;

if(isset($_SESSION['post_data']['PTYPE'])){
if ($_SESSION['post_data']['PTYPE'] == 'no pizza') {
$NOPIZZA='selected' ;
}elseif ($_SESSION['post_data']['PTYPE'] == 'cheese') {
$CHEESE='selected' ;
}elseif ($_SESSION['post_data']['PTYPE'] =='pepporoni') {
$PEPPORONI='selected' ;
}elseif ($_SESSION['post_data']['PTYPE']=='veggie') {
$VEGGIE='selected' ;
}elseif ($_SESSION['post_data']['PTYPE'] =='meat lovers') {
$MEAT='selected' ;
}
}

Link to comment
Share on other sites

ok well i got this at the top of the page:

 

Array

(

    [post_data] => Array

        (

        )

 

    [ORDER] => delivery

    [PTYPE] => cheese

    [DTYPE] => Bottled Fanta

    [PSIZE] => Small

    [DSIZE] => 2 liter

    [PTYPE2] => pepporoni

    [DTYPE2] => Bottled Fanta

    [PSIZE2] => Medium

    [DSIZE2] => 1 liter

    [PTYPE3] => pepporoni

    [DTYPE3] => Bottled Sprite

    [PSIZE3] => Medium

    [DSIZE3] => 1 liter

)

 

and the code i put was this

<?php



session_start();  //start session;
$_SESSION['post_data'] = $_POST; //store all post data to the session array.

echo '<pre>' . print_r($_SESSION,true) . '</pre>';

/*if(isset($_POST['ORDER'])) {
$ORDER = $_POST['ORDER'];
}
if(isset($_POST['PTYPE'])) {
$PTYPE = $_POST['PTYPE'];
}
if(isset($_POST['DTYPE'])) {
$DTYPE = $_POST['DTYPE'];
}
if(isset($_POST['PSIZE'])) {
$PSIZE = $_POST['PSIZE'];
}
if(isset($_POST['DSIZE'])) {
$DSIZE = $_POST['DSIZE'];
}
if(isset($_POST['PTYPE2'])) {
$PTYPE2 = $_POST['PTYPE2'];
}
if(isset($_POST['DTYPE2'])) {
$DTYPE2 = $_POST['DTYPE2'];
}
if(isset($_POST['PSIZE2'])) {
$PSIZE2 = $_POST['PSIZE2'];
}
if(isset($_POST['DSIZE2'])) {
$DSIZE2 = $_POST['DSIZE2'];
}
if(isset($_POST['PTYPE3'])) {
$PTYPE3 = $_POST['PTYPE3'];
}
if(isset($_POST['DTYPE3'])) {
$DTYPE3 = $_POST['DTYPE3'];
}
if(isset($_POST['PSIZE3'])) {
$PSIZE3 = $_POST['PSIZE3'];
}
if(isset($_POST['DSIZE3'])) {
$DSIZE3 = $_POST['DSIZE3'];
}
*/


echo "Order Type: <br/> \n";
echo"<form method='post' action='project2.php'>";
//set the variables.
$DEL = NULL;
$TAKE = NULL;
$EAT = NULL;

if(isset($_SESSION['post_data']['ORDER'])){
if ($_SESSION['post_data']['ORDER'] == 'delivery') {
$DEL='selected' ;
}elseif ($_SESSION['post_data']['ORDER'] == 'takeout') {
$TAKE='selected' ;
}elseif ($_SESSION['post_data']['ORDER'] =='eatin') {
$EAT='selected' ;
}
}



echo"Delivery <input type='radio' name='ORDER' value='delivery' $DEL> \n"  ;
if(isset($DEL)){
echo $DEL;
}
echo"Take Out <input type='radio' name='ORDER' value='takeout' $TAKE> \n"   ;
if(isset($TAKE)){
echo $TAKE;  
} 
echo"Eat in <input type='radio' name='ORDER' value='eatin' $EAT>\n" ;
if(isset($EAT)){
echo $EAT;
}
//set the variables.
$NOPIZZA = NULL;
$CHEESE = NULL;
$PEPPORONI = NULL;
$VEGGIE = NULL;
$MEAT = NULL;

if(isset($_SESSION['post_data']['PTYPE'])){
if ($_SESSION['post_data']['PTYPE'] == 'no pizza') {
$NOPIZZA='selected' ;
}elseif ($_SESSION['post_data']['PTYPE'] == 'cheese') {
$CHEESE='selected' ;
}elseif ($_SESSION['post_data']['PTYPE'] =='pepporoni') {
$PEPPORONI='selected' ;
}elseif ($_SESSION['post_data']['PTYPE']=='veggie') {
$VEGGIE='selected' ;
}elseif ($_SESSION['post_data']['PTYPE'] =='meat lovers') {
$MEAT='selected' ;
}
}

echo $CHEESE ;

echo"<br/>Pizza: <select name='PTYPE'>\n";
echo"<option></option>\n";
echo"<option $NOPIZZA>no pizza</option>\n";
echo"<option $CHEESE>cheese</option>\n";
echo"<option $PEPPORONI>pepporoni</option>\n";
echo"<option $VEGGIE>veggie</option>\n";
echo"<option $MEAT>meat lovers</option>\n";
echo"</select> \n";

and then it continues for the rest of the form but I haven't written the IF statements yet because I want to make sure the first ones work before I try the rest

Link to comment
Share on other sites

session_register

Warning

 

This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.

 

I wouldn't do that.

 

1. You already have the POST data in your SESSION array, as is evident with that print_r.

2. This is because you already have called session_start();

 

 

So, now you need to make sure you have session_start at the top of EACH page that you want to use these variables.  They will reside inside the same variables as long as the session is started.

 

I can help you, but I need the form flow.  As in the start of the order, flowing to the end of the order.  Otherwise, I could just give you snippets all day without ever getting it to work right.

Link to comment
Share on other sites

If I post the code can you just tell me how to fix it please?  I honestly have no clue why it doesnt work. 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Title of the document</title>
<meta name="description" content="Type a Short Description Here" />
<meta name="keywords" content="type, keywords, here" />
<meta name="author" content="Your Name" />
<meta http-equiv="content-type" content="text/html;charset=UTF-8" /> 
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>

<body>
<?php



session_start();  //start session;
$_SESSION['post_data'] = $_POST; //store all post data to the session array.

echo '<pre>' . print_r($_SESSION,true) . '</pre>';

/*if(isset($_POST['ORDER'])) {
$ORDER = $_POST['ORDER'];
}
if(isset($_POST['PTYPE'])) {
$PTYPE = $_POST['PTYPE'];
}
if(isset($_POST['DTYPE'])) {
$DTYPE = $_POST['DTYPE'];
}
if(isset($_POST['PSIZE'])) {
$PSIZE = $_POST['PSIZE'];
}
if(isset($_POST['DSIZE'])) {
$DSIZE = $_POST['DSIZE'];
}
if(isset($_POST['PTYPE2'])) {
$PTYPE2 = $_POST['PTYPE2'];
}
if(isset($_POST['DTYPE2'])) {
$DTYPE2 = $_POST['DTYPE2'];
}
if(isset($_POST['PSIZE2'])) {
$PSIZE2 = $_POST['PSIZE2'];
}
if(isset($_POST['DSIZE2'])) {
$DSIZE2 = $_POST['DSIZE2'];
}
if(isset($_POST['PTYPE3'])) {
$PTYPE3 = $_POST['PTYPE3'];
}
if(isset($_POST['DTYPE3'])) {
$DTYPE3 = $_POST['DTYPE3'];
}
if(isset($_POST['PSIZE3'])) {
$PSIZE3 = $_POST['PSIZE3'];
}
if(isset($_POST['DSIZE3'])) {
$DSIZE3 = $_POST['DSIZE3'];
}
*/


echo "Order Type: <br/> \n";
echo"<form method='post' action='project2.php'>";
//set the variables.
$DEL = NULL;
$TAKE = NULL;
$EAT = NULL;

if(isset($_SESSION['post_data']['ORDER'])){
if ($_SESSION['post_data']['ORDER'] == 'delivery') {
$DEL='selected' ;
}elseif ($_SESSION['post_data']['ORDER'] == 'takeout') {
$TAKE='selected' ;
}elseif ($_SESSION['post_data']['ORDER'] =='eatin') {
$EAT='selected' ;
}
}



echo"Delivery <input type='radio' name='ORDER' value='delivery' $DEL> \n"  ;
if(isset($DEL)){
echo $DEL;
}
echo"Take Out <input type='radio' name='ORDER' value='takeout' $TAKE> \n"   ;
if(isset($TAKE)){
echo $TAKE;  
} 
echo"Eat in <input type='radio' name='ORDER' value='eatin' $EAT>\n" ;
if(isset($EAT)){
echo $EAT;
}
//set the variables.
$NOPIZZA = NULL;
$CHEESE = NULL;
$PEPPORONI = NULL;
$VEGGIE = NULL;
$MEAT = NULL;

if(isset($_SESSION['post_data']['PTYPE'])){
if ($_SESSION['post_data']['PTYPE'] == 'no pizza') {
$NOPIZZA='selected' ;
}elseif ($_SESSION['post_data']['PTYPE'] == 'cheese') {
$CHEESE='selected' ;
}elseif ($_SESSION['post_data']['PTYPE'] =='pepporoni') {
$PEPPORONI='selected' ;
}elseif ($_SESSION['post_data']['PTYPE']=='veggie') {
$VEGGIE='selected' ;
}elseif ($_SESSION['post_data']['PTYPE'] =='meat lovers') {
$MEAT='selected' ;
}
}

echo $CHEESE ;

echo"<br/>Pizza: <select name='PTYPE'>\n";
echo"<option></option>\n";
echo"<option $NOPIZZA>no pizza</option>\n";
echo"<option $CHEESE>cheese</option>\n";
echo"<option $PEPPORONI>pepporoni</option>\n";
echo"<option $VEGGIE>veggie</option>\n";
echo"<option $MEAT>meat lovers</option>\n";
echo"</select> \n";

$PSIZE='unchecked' ;

if ($PSIZE=='Small'){
$SMALL='checked' ;
}


echo"    Pizza size: <select name='PSIZE'>\n";
echo"<option></option>";
echo"<option $SMALL>Small</option>";
echo"<option $MEDIUM>Medium</option>";
echo"<option $LARGE>Large</option>";
echo"</select>";

echo"<br/>Pizza2: <select name='PTYPE2'>\n";
echo"<option></option>\n";
echo"<option >no pizza</option>\n";
echo"<option >cheese</option>\n";
echo"<option >pepporoni</option>\n";
echo"<option >veggie</option>\n";
echo"<option >meat lovers</option>\n";
echo"</select> \n";

echo"Pizza size2: <select name='PSIZE2'>\n";
echo"<option></option>\n";
echo"<option>Small</option>\n";
echo"<option>Medium</option>\n";
echo"<option>Large</option>\n";
echo"</select>\n";

echo"<br/>Pizza3: <select name='PTYPE3'>\n";
echo"<option></option>\n";
echo"<option >no pizza</option>\n";
echo"<option >cheese</option>\n";
echo"<option >pepporoni</option>\n";
echo"<option >veggie</option>\n";
echo"<option >meat lovers</option>\n";
echo"</select> \n";

echo"Pizza size3: <select name='PSIZE3'>\n";
echo"<option></option>\n";
echo"<option>Small</option>\n";
echo"<option>Medium</option>\n";
echo"<option>Large</option>\n";
echo"</select>\n";

echo"</br> <br/>What drink would you like? <select name='DTYPE'>\n";
echo"<option></option>\n";
echo"<option>No drink</option>\n";
echo"<option>Bottled Pepsi</option>\n";
echo"<option>Bottled Fanta</option>\n";
echo"<option>Bottled Sprite</option>\n";
echo"<option>Bottled RootBeer</option>\n";
echo"</select>\n";

echo"Drink size: <select name='DSIZE'>\n";
echo"<option></option>\n";
echo"<option>.5 liter</option>\n";
echo"<option>1 liter</option>\n";
echo"<option>2 liter</option>\n";
echo"</select>\n";


echo"</br> <br/>What second drink would you like? <select name='DTYPE2'>\n";
echo"<option></option>\n";
echo"<option>No drink</option>\n";
echo"<option>Bottled Pepsi</option>\n";
echo"<option>Bottled Fanta</option>\n";
echo"<option>Bottled Sprite</option>\n";
echo"<option>Bottled RootBeer</option>\n";
echo"</select>\n";

echo"Drink size2: <select name='DSIZE2'>\n";
echo"<option></option>\n";
echo"<option>.5 liter</option>\n";
echo"<option>1 liter</option>\n";
echo"<option>2 liter</option>\n";
echo"</select>\n";


echo"</br> <br/>What third drink would you like? <select name='DTYPE3'>\n";
echo"<option></option>\n";
echo"<option>No drink</option>\n";
echo"<option>Bottled Pepsi</option>\n";
echo"<option>Bottled Fanta</option>\n";
echo"<option>Bottled Sprite</option>\n";
echo"<option>Bottled RootBeer</option>\n";
echo"</select>\n";

echo"Drink size3: <select name='DSIZE3'>\n";
echo"<option></option>\n";
echo"<option>.5 liter</option>\n";
echo"<option>1 liter</option>\n";
echo"<option>2 liter</option>\n";
echo"</select>\n";






echo"<br/> <br/> <input type='submit' value='submit your order' name='submit'>";
echo"</form>";


?>
</body>
</html>

and then the code for the 2nd page

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Title of the document</title>
<meta name="description" content="Type a Short Description Here" />
<meta name="keywords" content="type, keywords, here" />
<meta name="author" content="Your Name" />
<meta http-equiv="content-type" content="text/html;charset=UTF-8" /> 
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>

<body>
<?php

print_r ($_REQUEST) ;

$_SESSION['post_data'] = $_POST;

session_start();
$_SESSION['ORDER'] = $_POST['ORDER'];
$_SESSION['PTYPE'] = $_POST['PTYPE'];
$_SESSION['DTYPE'] = $_POST['DTYPE'];
$_SESSION['PSIZE'] = $_POST['PSIZE'];
$_SESSION['DSIZE'] = $_POST['DSIZE'];
$_SESSION['PTYPE2'] = $_POST['PTYPE2'];
$_SESSION['DTYPE2'] = $_POST['DTYPE2'];
$_SESSION['PSIZE2'] = $_POST['PSIZE2'];
$_SESSION['DSIZE2'] = $_POST['DSIZE2'];
$_SESSION['PTYPE3'] = $_POST['PTYPE3'];
$_SESSION['DTYPE3'] = $_POST['DTYPE3'];
$_SESSION['PSIZE3'] = $_POST['PSIZE3'];
$_SESSION['DSIZE3'] = $_POST['DSIZE3'];



$ORDER = $_POST['ORDER'];
$PTYPE = $_POST['PTYPE'];
$DTYPE = $_POST['DTYPE'];
$PSIZE = $_POST['PSIZE'];
$DSIZE = $_POST['DSIZE'];
$PTYPE2 = $_POST['PTYPE2'];
$DTYPE2 = $_POST['DTYPE2'];
$PSIZE2 = $_POST['PSIZE2'];
$DSIZE2 = $_POST['DSIZE2'];
$PTYPE3 = $_POST['PTYPE3'];
$DTYPE3 = $_POST['DTYPE3'];
$PSIZE3 = $_POST['PSIZE3'];
$DSIZE3 = $_POST['DSIZE3'];




if (($PTYPE=='cheese')and($PSIZE=='Small')) {
$PCOST=10 ;
}elseif (($PTYPE=='cheese')and($PSIZE=='Medium')) {
$PCOST=13 ;
}elseif (($PTYPE=='cheese')and($PSIZE=='Large')) {
$PCOST=15 ;
}elseif (($PTYPE=='pepporoni')and($PSIZE=='Small')) {
$PCOST=12 ;
}elseif (($PTYPE=='pepporoni')and($PSIZE=='Medium')) {
$PCOST=14 ;
}elseif (($PTYPE=='pepporoni')and($PSIZE=='Large')) {
$PCOST=16 ;
}elseif (($PTYPE=='veggie')and($PSIZE=='Small')) {
$PCOST=12 ;
}elseif (($PTYPE=='veggie')and($PSIZE=='Medium')) {
$PCOST=14 ;
}elseif (($PTYPE=='veggie')and($PSIZE=='Large')) {
$PCOST=16 ;
}elseif (($PTYPE=='meat lovers')and($PSIZE=='Small')) {
$PCOST=13 ;
}elseif (($PTYPE=='meat lovers')and($PSIZE=='Medium')) {
$PCOST=15 ;
}elseif (($PTYPE=='meat lovers')and($PSIZE=='Large')) {
$PCOST=17;
}else {
$PCOST=0 ;
}


if (($PTYPE2=='cheese')and($PSIZE2=='Small')) {
$PCOST2=10 ;
}elseif (($PTYPE2=='cheese')and($PSIZE2=='Medium')) {
$PCOST2=13 ;
}elseif (($PTYPE2=='cheese')and($PSIZE2=='Large')) {
$PCOST2=15 ;
}elseif (($PTYPE2=='pepporoni')and($PSIZE2=='Small')) {
$PCOST2=12 ;
}elseif (($PTYPE2=='pepporoni')and($PSIZE2=='Medium')) {
$PCOST2=14 ;
}elseif (($PTYPE2=='pepporoni')and($PSIZE2=='Large')) {
$PCOST2=16 ;
}elseif (($PTYPE2=='veggie')and($PSIZE2=='Small')) {
$PCOST2=12 ;
}elseif (($PTYPE2=='veggie')and($PSIZE2=='Medium')) {
$PCOST2=14 ;
}elseif (($PTYPE2=='veggie')and($PSIZE2=='Large')) {
$PCOST2=16 ;
}elseif (($PTYPE2=='meat lovers')and($PSIZE2=='Small')) {
$PCOST2=13 ;
}elseif (($PTYPE2=='meat lovers')and($PSIZE2=='Medium')) {
$PCOST2=15 ;
}elseif (($PTYPE2=='meat lovers')and($PSIZE2=='Large')) {
$PCOST2=17;
}else {
$PCOST2=0 ;
}


if (($PTYPE3=='cheese')and($PSIZE3=='Small')) {
$PCOST3=10 ;
}elseif (($PTYPE3=='cheese')and($PSIZE3=='Medium')) {
$PCOST3=13 ;
}elseif (($PTYPE3=='cheese')and($PSIZE3=='Large')) {
$PCOST3=15 ;
}elseif (($PTYPE3=='pepporoni')and($PSIZE3=='Small')) {
$PCOST3=12 ;
}elseif (($PTYPE3=='pepporoni')and($PSIZE3=='Medium')) {
$PCOST3=14 ;
}elseif (($PTYPE3=='pepporoni')and($PSIZE3=='Large')) {
$PCOST3=16 ;
}elseif (($PTYPE3=='veggie')and($PSIZE3=='Small')) {
$PCOST3=12 ;
}elseif (($PTYPE3=='veggie')and($PSIZE3=='Medium')) {
$PCOST3=14 ;
}elseif (($PTYPE3=='veggie')and($PSIZE3=='Large')) {
$PCOST3=16 ;
}elseif (($PTYPE3=='meat lovers')and($PSIZE3=='Small')) {
$PCOST3=13 ;
}elseif (($PTYPE3=='meat lovers')and($PSIZE3=='Medium')) {
$PCOST3=15 ;
}elseif (($PTYPE3=='meat lovers')and($PSIZE3=='Large')) {
$PCOST3=17;
}else {
$PCOST3=0 ;
}

if((($DTYPE=='Bottled Pepsi')or($DTYPE=='Bottled Fanta')or($DTYPE=='Bottled Sprite')or($DTYPE=='Bottled RootBeer'))and($DSIZE=='.5 liter')) {
$DCOST=.69 ;
}elseif((($DTYPE=='Bottled Pepsi')or($DTYPE=='Bottled Fanta')or($DTYPE=='Bottled Sprite')or($DTYPE=='Bottled RootBeer'))and($DSIZE=='1 liter')) {
$DCOST=.99 ;
}elseif((($DTYPE=='Bottled Pepsi')or($DTYPE=='Bottled Fanta')or($DTYPE=='Bottled Sprite')or($DTYPE=='Bottled RootBeer'))and($DSIZE=='2 liter')) {
$DCOST=1.69 ;
}elseif($DTYPE=='No drink'){
$DCOST=0 ;
}

if((($DTYPE2=='Bottled Pepsi')or($DTYPE2=='Bottled Fanta')or($DTYPE2=='Bottled Sprite')or($DTYPE2=='Bottled RootBeer'))and($DSIZE2=='.5 liter')) {
$DCOST2=.69 ;
}elseif((($DTYPE2=='Bottled Pepsi')or($DTYPE2=='Bottled Fanta')or($DTYPE2=='Bottled Sprite')or($DTYPE2=='Bottled RootBeer'))and($DSIZE2=='1 liter')) {
$DCOST2=.99 ;
}elseif((($DTYPE2=='Bottled Pepsi')or($DTYPE2=='Bottled Fanta')or($DTYPE2=='Bottled Sprite')or($DTYPE2=='Bottled RootBeer'))and($DSIZE2=='2 liter')) {
$DCOST2=1.69 ;
}elseif($DTYPE2=='No drink'){
$DCOST2=0 ;
}

if((($DTYPE3=='Bottled Pepsi')or($DTYPE3=='Bottled Fanta')or($DTYPE3=='Bottled Sprite')or($DTYPE3=='Bottled RootBeer'))and($DSIZE3=='.5 liter')) {
$DCOST3=.69 ;
}elseif((($DTYPE3=='Bottled Pepsi')or($DTYPE3=='Bottled Fanta')or($DTYPE3=='Bottled Sprite')or($DTYPE3=='Bottled RootBeer'))and($DSIZE3=='1 liter')) {
$DCOST3=.99 ;
}elseif((($DTYPE3=='Bottled Pepsi')or($DTYPE3=='Bottled Fanta')or($DTYPE3=='Bottled Sprite')or($DTYPE3=='Bottled RootBeer'))and($DSIZE3=='2 liter')) {
$DCOST3=1.69 ;
}elseif($DTYPE3=='No drink'){
$DCOST3=0 ;
}

$TOTAL=($PCOST+$PCOST3+$PCOST3+$DCOST+$DCOST2+$DCOST3) ;

echo "<br/><br/>Your Order is:<br/>" ;
echo " $PSIZE $PTYPE ($PCOST),$PSIZE2 $PTYPE2 ($PCOST2),$PSIZE3 $PTYPE3 ($PCOST3),  <br/>" ;
echo " $DSIZE $DTYPE ($DCOST),$DSIZE2 $DTYPE2 ($DCOST2),$DSIZE3 $DTYPE3 ($DCOST3), <br/> <br/>" ;
echo"<br/><br/>Your total price is: $TOTAL <br/> <br/>";






if ($ORDER=='delivery') {
echo"Please enter the information required for delivery <br/>" ;
echo "Address: <input type=text><br/>";
echo "City: <input type=text><br/>";
echo "Zip Code: <input type=text><br/>";
} elseif ($ORDER=='takeout') {
echo "Your order will be ready for pickup in 30 min";
} elseif ($ORDER=='eatin') {
echo "Your order will be ready in 30 min";
}

echo"<form action=asdf.php>";
echo"<br/> <input type=submit value='confirm this order'>"; 
echo"</form>";










echo "<form action=project.php>";
echo "<br/> <br/><input type=submit value='edit this order'>";
echo "<input type='hidden' name='ORDER' value='$ORDER'>";
echo "<input type='hidden' name='PTYPE' value='$PTYPE'>";
echo "<input type='hidden' name='PTYPE2' value='$PTYPE2'>";
echo "<input type='hidden' name='PTYPE3' value='$PTYPE3'>";
echo "<input type='hidden' name='PSIZE' value='$PSIZE'>";
echo "<input type='hidden' name='PSIZE2' value='$PSIZE2'>";
echo "<input type='hidden' name='PSIZE3' value='$PSIZE3'>";
echo "<input type='hidden' name='DTYPE' value='$DTYPE'>";
echo "<input type='hidden' name='DTYPE2' value='$DTYPE2'>";
echo "<input type='hidden' name='DTYPE3' value='$DTYPE3'>";
echo "<input type='hidden' name='DSIZE' value='$DSIZE'>";
echo "<input type='hidden' name='DSIZE2' value='$DSIZE2'>";
echo "<input type='hidden' name='DSIZE3' value='$DSIZE3'>";
echo "</form>";



?>
</body>
</html>

 

It recognizes all the variables, so I don't get why the IF statement doesnt work. Thank you so much

Link to comment
Share on other sites

Here you go:

project.php

<?php
//session start must come BEFORE any output to the page.
session_start();  //start session;
if($_SERVER['REQUEST_METHOD'] == 'POST') { //if there was a form posted.
$_SESSION['post_data'] = $_POST; //store all post data to the session array.
}
//debugging:
//echo '<pre>' . print_r($_SESSION,true) . '</pre>';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Title of the document</title>
<meta name="description" content="Type a Short Description Here" />
<meta name="keywords" content="type, keywords, here" />
<meta name="author" content="Your Name" />
<meta http-equiv="content-type" content="text/html;charset=UTF-8" /> 
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>

<body>
<?php
$number_of_pizzas_to_order = 3; //tell the form how many pizza's you would like to offer.

echo "Order Type: <br/> \n";
echo"<form method='post' action='project2.php'>";
//set the variables.
$DEL = NULL;
$TAKE = NULL;
$EAT = NULL;

//check the appropriate box.
if(isset($_SESSION['post_data']['ORDER'])){
if ($_SESSION['post_data']['ORDER'] == 'delivery') {
	$DEL='checked' ;
}elseif ($_SESSION['post_data']['ORDER'] == 'takeout') {
	$TAKE='checked' ;
}elseif ($_SESSION['post_data']['ORDER'] =='eatin') {
	$EAT='checked' ;
}
} else {
$TAKE = 'checked';
}



echo "Delivery <input type='radio' name='ORDER' value='delivery' $DEL> \n

Take Out <input type='radio' name='ORDER' value='takeout' $TAKE> \n

Eat in <input type='radio' name='ORDER' value='eatin' $EAT>\n";

//set the variables.

//build form dynamically. Allows for edits.
for($i = 1; $i <= $number_of_pizzas_to_order; $i++) {
//preset variables.
$no_pizza 			= NULL;
$cheese			= NULL;
$pepporoni			= NULL;
$veggie			= NULL;
$meat_lovers		= NULL;
$Small				= NULL;
$Medium 			= NULL;
$Large 			= NULL;	
if(!empty($_SESSION['post_data']['pizza'][$i])) { //if this is an edit.
	$$_SESSION['post_data']['pizza'][$i]['type'] = 'selected="selected"'; //only select the right pizza type
	$$_SESSION['post_data']['pizza'][$i]['size'] = 'selected="selected"'; //and size
}
//echo a heredoc (cause I love em).
echo <<<EOF
<br/>Pizza {$i}: <select name='pizza[{$i}][type]'>\n
<option></option>\n
<option $no_pizza value="no_pizza">no pizza</option>\n
<option $cheese>cheese</option>\n
<option $pepporoni>pepporoni</option>\n
<option $veggie>veggie</option>\n
<option $meat_lovers value="meat_lovers">meat lovers</option>\n
</select> \n

    Pizza size: <select name='pizza[{$i}][size]'>\n
<option></option>
<option $Small>Small</option>
<option $Medium>Medium</option>
<option $Large>Large</option>
</select>
EOF;

}

//Build drink section dynamically, allowing for edits.
//just like above.
echo '</br> <br/>What drink would you like? <br />';

for($i = 1; $i <= $number_of_pizzas_to_order; $i++) {
$No_drink 			= NULL;
$Bottled_Pepsi 		= NULL;
$Bottled_Fanta   	= NULL;
$Bottled_Sprite     = NULL;
$Bottled_RootBeer   = NULL;
$halfLiter          = NULL;
$liter              = NULL;
$doubleLiter      	= NULL;
if(!empty($_SESSION['post_data']['drink'][$i])) {
	$$_SESSION['post_data']['drink'][$i]['type'] = 'selected="selected"';
	$$_SESSION['post_data']['drink'][$i]['size'] = 'selected="selected"';
}
echo <<<EOF
Drink {$i}:<select name='drink[{$i}][type]'>\n
<option></option>\n
<option $No_drink value="No_drink">No drink</option>\n
<option $Bottled_Pepsi value="Bottled_Pepsi">Bottled Pepsi</option>\n
<option $Bottled_Fanta value="Bottled_Fanta">Bottled Fanta</option>\n
<option $Bottled_Sprite value="Bottled_Sprite">Bottled Sprite</option>\n
<option $Bottled_RootBeer value="Bottled_RootBeer">Bottled RootBeer</option>\n
</select>\n

Drink size: <select name='drink[{$i}][size]'>\n
<option></option>\n
<option $halfLiter value="halfLiter">.5 liter</option>\n
<option $liter value="liter">1 liter</option>\n
<option $doubleLiter value="doubleLiter">2 liter</option>\n
</select>\n
EOF;
}

echo "<br/> <br/> <input type='submit' value='submit your order' name='submit'>
</form>";

?>
</body>
</html>

project2.php

<?php
session_start();
//always update the session post data.
$_SESSION['post_data'] = $_POST;

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Title of the document</title>
<meta name="description" content="Type a Short Description Here" />
<meta name="keywords" content="type, keywords, here" />
<meta name="author" content="Your Name" />
<meta http-equiv="content-type" content="text/html;charset=UTF-8" /> 
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>

<body>
<?php
//pizza's are in array now, you can add, delete, and change prices all in one place.
$pizza = array(
	'cheese' => array(10=>'Small',13=>'Medium',15=>'Large'),
	'pepporoni' => array(12=>'Small',14=>'Medium',16=>'Large'),
	'veggie' => array(12=>'Small',14=>'Medium',16=>'Large'),
	'meat lovers' => array(13=>'Small',15=>'Medium',17=>'Large')
	);
//drinks are in array, had to make it multi-dem to overcome a problem with spaces, and variable naming conventions.
$drink = array(
	'halfLiter' => array('.69' => '.5 liter'),
	'liter' => array('.99' => '1 liter'),
	'doubleLiter' => array('1.69' => '2 liter')
	);
$total = 0; //start our total at 0.
echo "<br/><br/>Your Order is:<br/>";
foreach($_SESSION['post_data']['pizza'] as $k => $v) { //go through our posted data. (pizza section).
$type = str_replace('_',' ',$v['type']); //handling variable naming by adding and removing underscores for spaces.
if(array_key_exists($type,$pizza)) {  //if the pizza type is in the pizza array.
	$_SESSION['post_data']['pizza'][$k]['price'] = array_search($v['size'],$pizza[$type]); //return the key (price) from that array, building another index into the session array.
} else {
	$_SESSION['post_data']['pizza'][$k]['price'] = 0.00; //else set it at 0.
}

//string below is the individual output for each pizza product.
$pizs[] = ucwords($type) . ' ' . $v['size'] .' (' . $_SESSION['post_data']['pizza'][$k]['price'] . ')'; //build our output string, and add it to an array.


$total += $_SESSION['post_data']['pizza'][$k]['price']; //add our price to the total.
}
foreach($_SESSION['post_data']['drink'] as $k => $v) { //go through the drink section of the posted data.
if(array_key_exists($v['size'],$drink)) { //if the size is in the drink array.
	$keys = array_keys($drink[$v['size']]); //get the keys of that array (only 1 exists), this key is the price.
	$size = $drink[$v['size']][$keys[0]]; //now we request the contents of that key, which is the real size (had to be done to allow for editing the original form).
	$_SESSION['post_data']['drink'][$k]['price'] = $keys[0]; //now add the price to a new index in the drink array.
} else {
	$_SESSION['post_data']['drink'][$k]['price'] = 0.00; //unless it doesn't exist, then we make it 0.
}

//string below is the individual output for each drink product
$drks[] = str_replace('_',' ',$v['type']) . ' ' . $size .' (' . $_SESSION['post_data']['drink'][$k]['price'] . ')'; //the string for each drink now goes to the drks array.


$total += $_SESSION['post_data']['drink'][$k]['price']; //and the price gets added to the total.
}	

//next we tie the pizs array together with a comma, break the rule, then tie the drks array together with a comma.  Finally sending our total to the screen.
echo implode(',',$pizs) . '<br />' . implode(',',$drks) . '<br /><br />
<br/><br/>Your total price is: ' . $total . '<br/> <br/>';

//debugging.
//echo '<pre>' . print_r($_SESSION,true) . '</pre>';


//pretty much the same as you had, just changed where to look for it.
if ($_SESSION['post_data']['ORDER']=='delivery') {
echo"Please enter the information required for delivery <br/>" ;
echo "Address: <input type=text><br/>";
echo "City: <input type=text><br/>";
echo "Zip Code: <input type=text><br/>";
} elseif ($_SESSION['post_data']['ORDER']=='takeout') {
echo "Your order will be ready for pickup in 30 min";
} elseif ($_SESSION['post_data']['ORDER']=='eatin') {
echo "Your order will be ready in 30 min";
}

echo"<form action=asdf.php>";
echo"<br/> <input type=submit value='confirm this order'>"; 
echo"</form>";

//we don't have to send hidden fields, all the info is in the session. As long as it is a GET form.
echo "<form action='project.php'>
<br/> <br/><input type=submit value='edit this order'>
</form>";
?>
</body>
</html>

 

Fully commented up.  There are ways to tighten it up a bit, I'll let you work on that.

Link to comment
Share on other sites

  • 3 weeks later...

Thank you so much I really appreciate it. The only thing is that I'm not very good at PHP and I don't understand a lot of the things.  Would it be possible to just change code around slightly in order to make it work? It's not that important if its effecient and neat, I haven't learned any of that stuff yet in the class I am currently taken.

 

I apologize for asking you once again to work, and I completely understand if you don't want to.  Thank you once again.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.