To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
Multiple forms on page processed by single php script
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.
<?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
$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';
Is there any reason you've split the page up into different forms? Why not just use one form?
__________________
***If your problem has been solved, PLEASE click the RESOLVED LINK under "Thread Tools"***
"Well Bones, do the new medical facilities meet with your approval?" -- Kirk
"They do not. It's like working in a damn computer center" -- McCoy (Star Trek: TMP)
The reason I want to use multiple forms is because I want each of the different elements to be separate from another, only coming together at the end of the process via session variables. I could put the code for each of the different elements in a different php script, but I need them to submit to PHP_SELF so that the page reloads with the new information.
Is there a way to 'name' a php script, and then tell a form to be processed by that script?
If you want to separate elements, than why not use SPAN/DIV tags?
At any rate, other than using JS to combine the forms into one before submission, I don't know how else to accomplish this.
__________________
***If your problem has been solved, PLEASE click the RESOLVED LINK under "Thread Tools"***
"Well Bones, do the new medical facilities meet with your approval?" -- Kirk
"They do not. It's like working in a damn computer center" -- McCoy (Star Trek: TMP)
Well, I guess what I really need to know is... why do you need to separate these 'elements' ? For example, what kind of separation? Do you simply mean visible separation as displayed in the browser? Or is there some code-level reason you're separating them?
__________________
***If your problem has been solved, PLEASE click the RESOLVED LINK under "Thread Tools"***
"Well Bones, do the new medical facilities meet with your approval?" -- Kirk
"They do not. It's like working in a damn computer center" -- McCoy (Star Trek: TMP)
There is a store that sells several items: portraits, cards, proofs....
The portraits have several attributes that need to be selected, the cards have one, the proofs don't have any.
I want to be able to have the customer be able to select a portrait, with all the different attributes, without affecting the selection of cards or proofs. I also want all of these things to be displayed on different parts of the same page.
Location: Rapid Offensive Unit "Foreign Object Damage"
Posts: 19,122
If you're separating them into sections, then why have them all on the same page? You can still have them in the same file, but be more judicious about which part of the form to output, depending on which ones have already been filled in. You certainly don't need the entire form data to be available in forms through the whole process if you're storing it in session variables.
__________________
On two occasions I have been asked [by Members of Parliament], "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.