I am trying to create a page with several forms...all of them are submitted to PHP_SELF. There is one php script on this page. The problem is that only the first form is getting processed. The others are not getting processed at all, and when I click on "submit", nothing happens.
Here is the code for the form.php page
<html><head>
<script type="text/javascript">
<!--
function otherSelect() {
var other = document.getElementById("frame2");
if (document.forms[0].size.options[document.forms[0].size.selectedIndex].value == "5x7") {
frame2.style.visibility = "visible";
}
else {
frame2.style.visibility = "hidden";
}
}
//-->
</script>
<title>LifetouchOrderSystem</title></head><body>
<table width="760" border="1">
<tr>
<td width="239"><h4></h4>
<form action="<?php $PHP_SELF;?>" method="post">
<p>Pose
<select name="pose">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<a href="../testing/sessionVariables.php"><img src="../images/SPACER.gif" width="23" height="12" border="0"></a> Quantity
<input name="quantity" type="text" value="1" size="3" maxlength="3">
<br>
<br>
Size
<select name="size" onchange="otherSelect()">
<option value="wallets">Wallets</option>
<option value="5x7">5 x 7</option>
<option value="8x10" selected>8 x 10</option>
<option value="10x13">10 x 13</option>
<option value="16x20">16 x 20</option>
<option value="20x24">20 x 24</option>
</select>
Finish
<select name="finish">
<option value="basic" selected>Basic</option>
<option value="premier">Premier</option>
<option value="heirloom">Heirloom</option>
</select>
<br>
<input type="hidden" name="_submit_check" value="1"/>
<br />Gallery
<select name="gallery">
<option value="" selected></option>
<option value="BW">Black & White</option>
<option value="SEP">Sepia</option>
<option value="OMB">Oval Matte Burgundy</option>
<option value="RMB">Rectangular Matte Burgundy</option>
<option value="OMC">Oval Matte Charcoal</option>
<option value="RMC">Rectangular Matte Charcoal</option>
<option value="DES">Deckled Edge Sepia</option>
<option value="OMM">Oval Matte Marble</option>
<option value="RMM">Rectangular Matte Marble</option>
<option value="OMP">Oval Matte Parchment</option>
<option value="TCR">Touch of Color Rose</option>
<option value="TOCR">Touch of Color Rings</option>
<option value="TOCC">Touch of Color Cross</option>
</select>
<br>
<br>
<br>
<br>
Frame
<select name="frame">
<option value="" selected></option>
<option value="LO">Light Oak</option>
<option value="BK">Black</option>
<option value="S">Silver</option>
<option value="CE">Cherry Leaf Embossed</option>
<option value="ME">Pecan Leaf Embossed</option>
<option value="GS">Gold Speckled</option>
<option value="OG">Gold Marble</option>
</select>
<br />
<div id="frame2" style="visibility: hidden;">
<a href="sessionVariables.php"><img src="../images/SPACER.gif" width="35" height="12" border="0"></a>
<select name="frame2">
<option value="LO">Light Oak</option>
<option value="BK">Black</option>
<option value="S">Silver</option>
<option value="CE">Cherry Leaf Embossed</option>
<option value="ME">Maple Leaf Embossed</option>
<option value="GS">Gold Speckled</option>
<option value="OG">Gold Marble</option>
</select>
</div>
<br>
<input type="hidden" name="session_name" value="cart">
<br>
<input type="submit">
</p>
</form>
<br /> <br /> <br /> <br />
<form name = "retouch" id = "retouch" action="<?php $PHP_SELF;?>" method="post">
Retouch
<input name="retouch" type="checkbox" id="retouch" value="retouch">
<input type="hidden" name="session_name" value="cart">
<br>
<input type="submit">
</form>
<form name = "proofs" id = "proofs" action="<?php $PHP_SELF;?>" method="post">
Proofs
<input name="proofs" type="checkbox" id="proofs" value="proofs">
<input type="hidden" name="session_name" value="cart">
<br>
<input type="submit">
</form>
<form name = "cards" id = "cards" action="<?php $PHP_SELF;?>" method="post">
Cards
<input name="cards" type="text" id="cards" value="0" size="3" maxlength="5">
<input type="hidden" name="session_name" value="cart">
<br>
<input type="submit">
</form>
</td>
<td width="505">
<?php
include 'processForm.php';
?>
</td>
</tr>
</table>
<p><a href="sessionDestroy.php">Destroy Session </a> <a href="sessionVariables.php"><img src="../images/SPACER.gif" width="14" height="14" border="0">Global variables </a></p> <!--destroy session-->
</body></html>
Here is the code for the processForm.php
<?php
session_start();
//create session variables for various parameters
$_SESSION['order'];
$_SESSION['totalPrice'];
$_SESSION['basicCost'];
$_SESSION['finishUpgrade'];
$_SESSION['totalBasicPoints'];
$_SESSION['productNumber'];
$_SESSION['basicCost'];
$_SESSION['extraPoint'];
$_SESSION['upgradedPrice'];
$_SESSION['totalCost'];
if (array_key_exists('_submit_check', $_POST)) { //test whether form has been submitted
$pose = $_POST['pose'];
$quantity = $_POST['quantity'];
$size = $_POST['size'];
$finish = $_POST['finish'];
$gallery = $_POST['gallery'];
$retouch = $_POST['retouch'];
$cards = $_POST['cards'];
$proofs = $_POST['proofs'];
$frame1 = $_POST['frame1'];
$frame2 = $_POST['frame2']; //put form elements into variables
$formArray=array($pose,$quantity,$size,$finish,$gallery,$frame1,$frame2); //put form variables into array
$_SESSION['order'][] = $formArray; //put array of form variables into 2d session array
include 'sizeCase.php';
$finishPoints=$basicPoints; //create a value for the finishCase.php to work off of.
$basicPoints*=$quantity; //create a total value of basic points by multiplying number of points per item by number of items
$_SESSION['totalBasicPoints'] +=$basicPoints; //create running total of basic points
include 'packageCase.php'; //determine how much each package is - each set of points.
$_SESSION['basicCost'] = $basicCost; //create session variable for cost of basic points
include 'finishCase.php'; //determine how much each finish adds to total
$_SESSION['extraPoint'] += $extraPoint; //add extra point if applicable from packageCase.php
$_SESSION['finishUpgrade'] += $finishUpgrade; //create session variable for cost of upgrades, add current upgrade cost to total
$_SESSION['upgradedPrice']= $_SESSION['finishUpgrade'] + $_SESSION['basicCost']; //calculate total cost by adding basic cost to upgrade cost
include 'cards.php';
include 'proofs.php';
include 'retouch.php';
$_SESSION['totalCost'] = $_SESSION['upgradedPrice']+$_SESSION['cards']+$_SESSION['proofs'];
include 'productPrint.php';
include 'totalPrint.php';
}
?>