Jump to content

Recommended Posts

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--][div class=\'htmltop\']HTML[/div][div class=\'htmlmain\'][!--html1--]<[color=blue]html[/color]><[color=blue]head[/color]>
<script type="[color=orange]text/javascript[/color]">
<!--
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";
}
}
//-->
<[color=blue]/script[/color]>
<[color=blue]title[/color]>LifetouchOrderSystem<[color=blue]/title[/color]><[color=blue]/head[/color]><[color=blue]body[/color]>

<[color=blue]table width[/color]="[color=orange]760[/color]" border="[color=orange]1[/color]">
<[color=blue]tr[/color]>
<[color=blue]td width[/color]="[color=orange]239[/color]"><[color=blue]h4[/color]><[color=blue]/h4[/color]>
<[color=blue]form action[/color]="[color=orange]<?php $PHP_SELF;?>[/color]" method="[color=orange]post[/color]">

<[color=blue]p[/color]>Pose
<[color=blue]select name[/color]="[color=orange]pose[/color]">
<[color=blue]option value[/color]="[color=orange]1[/color]" selected>1<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]2[/color]">2<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]3[/color]">3<[color=blue]/option[/color]>
<[color=blue]/select[/color]>
<[color=blue]a href[/color]="[color=orange]../testing/sessionVariables.php[/color]"><[color=blue]img src[/color]="[color=orange]../images/SPACER.gif[/color]" width="[color=orange]23[/color]" height="[color=orange]12[/color]" border="[color=orange]0[/color]"><[color=blue]/a[/color]> Quantity
<[color=blue]input name[/color]="[color=orange]quantity[/color]" type="[color=orange]text[/color]" value="[color=orange]1[/color]" size="[color=orange]3[/color]" maxlength="[color=orange]3[/color]">
<[color=blue]br[/color]>
<[color=blue]br[/color]>
Size
<[color=blue]select name[/color]="[color=orange]size[/color]" onchange="[color=orange]otherSelect()[/color]">
<[color=blue]option value[/color]="[color=orange]wallets[/color]">Wallets<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]5x7[/color]">5 x 7<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]8x10[/color]" selected>8 x 10<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]10x13[/color]">10 x 13<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]16x20[/color]">16 x 20<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]20x24[/color]">20 x 24<[color=blue]/option[/color]>
<[color=blue]/select[/color]>
Finish
<[color=blue]select name[/color]="[color=orange]finish[/color]">
<[color=blue]option value[/color]="[color=orange]basic[/color]" selected>Basic<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]premier[/color]">Premier<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]heirloom[/color]">Heirloom<[color=blue]/option[/color]>
<[color=blue]/select[/color]>
<[color=blue]br[/color]>
<[color=blue]input type[/color]="[color=orange]hidden[/color]" name="[color=orange]_submit_check[/color]" value="1"/>
<[color=blue]br /[/color]>Gallery
<[color=blue]select name[/color]="[color=orange]gallery[/color]">
<[color=blue]option value[/color]="[color=orange][/span]" selected><[span style=\'color:blue\']/option[/color]>
<[color=blue]option value[/color]="[color=orange]BW[/color]">Black & White<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]SEP[/color]">Sepia<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]OMB[/color]">Oval Matte Burgundy<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]RMB[/color]">Rectangular Matte Burgundy<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]OMC[/color]">Oval Matte Charcoal<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]RMC[/color]">Rectangular Matte Charcoal<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]DES[/color]">Deckled Edge Sepia<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]OMM[/color]">Oval Matte Marble<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]RMM[/color]">Rectangular Matte Marble<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]OMP[/color]">Oval Matte Parchment<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]TCR[/color]">Touch of Color Rose<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]TOCR[/color]">Touch of Color Rings<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]TOCC[/color]">Touch of Color Cross<[color=blue]/option[/color]>
<[color=blue]/select[/color]>
<[color=blue]br[/color]>
<[color=blue]br[/color]>
<[color=blue]br[/color]>
<[color=blue]br[/color]>
Frame
<[color=blue]select name[/color]="[color=orange]frame[/color]">
<[color=blue]option value[/color]="[color=orange][/span]" selected><[span style=\'color:blue\']/option[/color]>
<[color=blue]option value[/color]="[color=orange]LO[/color]">Light Oak<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]BK[/color]">Black<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]S[/color]">Silver<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]CE[/color]">Cherry Leaf Embossed<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]ME[/color]">Pecan Leaf Embossed<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]GS[/color]">Gold Speckled<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]OG[/color]">Gold Marble<[color=blue]/option[/color]>
<[color=blue]/select[/color]>
<[color=blue]br /[/color]>
<[color=blue]div id[/color]="[color=orange]frame2[/color]" style="[color=orange]visibility: hidden;[/color]">
<[color=blue]a href[/color]="[color=orange]sessionVariables.php[/color]"><[color=blue]img src[/color]="[color=orange]../images/SPACER.gif[/color]" width="[color=orange]35[/color]" height="[color=orange]12[/color]" border="[color=orange]0[/color]"><[color=blue]/a[/color]>
<[color=blue]select name[/color]="[color=orange]frame2[/color]">
<[color=blue]option value[/color]="[color=orange]LO[/color]">Light Oak<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]BK[/color]">Black<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]S[/color]">Silver<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]CE[/color]">Cherry Leaf Embossed<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]ME[/color]">Maple Leaf Embossed<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]GS[/color]">Gold Speckled<[color=blue]/option[/color]>
<[color=blue]option value[/color]="[color=orange]OG[/color]">Gold Marble<[color=blue]/option[/color]>
<[color=blue]/select[/color]>
<[color=blue]/div[/color]>

<[color=blue]br[/color]>
<[color=blue]input type[/color]="[color=orange]hidden[/color]" name="[color=orange]session_name[/color]" value="[color=orange]cart[/color]">
<[color=blue]br[/color]>
<[color=blue]input type[/color]="[color=orange]submit[/color]">
<[color=blue]/p[/color]>
<[color=blue]/form[/color]>
<[color=blue]br /[/color]> <[color=blue]br /[/color]> <[color=blue]br /[/color]> <[color=blue]br /[/color]>
<[color=blue]form name [/color]= "retouch" id = "retouch" action="[color=orange]<?php $PHP_SELF;?>[/color]" method="[color=orange]post[/color]">
Retouch
<[color=blue]input name[/color]="[color=orange]retouch[/color]" type="[color=orange]checkbox[/color]" id="[color=orange]retouch[/color]" value="[color=orange]retouch[/color]">
<[color=blue]input type[/color]="[color=orange]hidden[/color]" name="[color=orange]session_name[/color]" value="[color=orange]cart[/color]">
<[color=blue]br[/color]>
<[color=blue]input type[/color]="[color=orange]submit[/color]">
<[color=blue]/form[/color]>

<[color=blue]form name [/color]= "proofs" id = "proofs" action="[color=orange]<?php $PHP_SELF;?>[/color]" method="[color=orange]post[/color]">
Proofs
<[color=blue]input name[/color]="[color=orange]proofs[/color]" type="[color=orange]checkbox[/color]" id="[color=orange]proofs[/color]" value="[color=orange]proofs[/color]">
<[color=blue]input type[/color]="[color=orange]hidden[/color]" name="[color=orange]session_name[/color]" value="[color=orange]cart[/color]">
<[color=blue]br[/color]>
<[color=blue]input type[/color]="[color=orange]submit[/color]">
<[color=blue]/form[/color]>

<[color=blue]form name [/color]= "cards" id = "cards" action="[color=orange]<?php $PHP_SELF;?>[/color]" method="[color=orange]post[/color]">
Cards
<[color=blue]input name[/color]="[color=orange]cards[/color]" type="[color=orange]text[/color]" id="[color=orange]cards[/color]" value="[color=orange]0[/color]" size="[color=orange]3[/color]" maxlength="[color=orange]5[/color]">
<[color=blue]input type[/color]="[color=orange]hidden[/color]" name="[color=orange]session_name[/color]" value="[color=orange]cart[/color]">
<[color=blue]br[/color]>
<[color=blue]input type[/color]="[color=orange]submit[/color]">
<[color=blue]/form[/color]>
<[color=blue]/td[/color]>
<[color=blue]td width[/color]="[color=orange]505[/color]">&nbsp;

<?php
include 'processForm.php';
?>
<[color=blue]/td[/color]>
<[color=blue]/tr[/color]>
<[color=blue]/table[/color]>
<[color=blue]p[/color]><[color=blue]a href[/color]="[color=orange]sessionDestroy.php[/color]">Destroy Session <[color=blue]/a[/color]> <[color=blue]a href[/color]="[color=orange]sessionVariables.php[/color]"><[color=blue]img src[/color]="[color=orange]../images/SPACER.gif[/color]" width="[color=orange]14[/color]" height="[color=orange]14[/color]" border="[color=orange]0[/color]">Global variables <[color=blue]/a[/color]><[color=blue]/p[/color]> <![color=red]--destroy session--[/color]>
<[color=blue]/body[/color]><[color=blue]/html[/color]>[!--html2--][/div][!--html3--]

Here is the code for the processForm.php

[code=php:0]
<?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';

}
?>

[/code]
Seems to be the problem is that each form would need its own submit button, and the submit button would only submit the contents of the associated form. Or do you mean to say that even if you use the other submit buttons associated with different forms, they do not submit/the information does not get through?

Also, you should validate the submitted information before dumping it into a variable for use by a script. Never, ever trust user supplied information.
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.