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
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > Misc Help > ClientSide Technologies

ClientSide Technologies Discuss HTML/CSS/Javascript, and any other client-side technologies, here.

Reply
 
Thread Tools Rate Thread Display Modes
Old 04-01-2006, 09:37 PM   #1
mister_t101
Learner
 
Join Date: Mar 2006
Location: Long Pond, PA
Posts: 14
Question 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.

Here is the code for the form.php page

HTML Code:
<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">&nbsp;
	
<?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 Code:
<?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';

}
?>
mister_t101 is offline   Reply With Quote
Old 04-01-2006, 09:45 PM   #2
bradgrafelman
Pna lbh ernq guvf?
 
Join Date: Jul 2004
Location: 40.566N -89.731W, ~469ft above sea level
Posts: 11,488
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)

Useful links: Debugging 101 || NJOE || (Sig image) || Rolla Engineered Solutions, LLC
bradgrafelman is offline   Reply With Quote
Old 04-01-2006, 09:50 PM   #3
mister_t101
Learner
 
Join Date: Mar 2006
Location: Long Pond, PA
Posts: 14
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?
mister_t101 is offline   Reply With Quote
Old 04-01-2006, 09:54 PM   #4
bradgrafelman
Pna lbh ernq guvf?
 
Join Date: Jul 2004
Location: 40.566N -89.731W, ~469ft above sea level
Posts: 11,488
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)

Useful links: Debugging 101 || NJOE || (Sig image) || Rolla Engineered Solutions, LLC
bradgrafelman is offline   Reply With Quote
Old 04-01-2006, 10:03 PM   #5
mister_t101
Learner
 
Join Date: Mar 2006
Location: Long Pond, PA
Posts: 14
How would I go about using span/div tags in this situation?

I would be willing to use JS, but don't really know how to go about it
mister_t101 is offline   Reply With Quote
Old 04-01-2006, 10:05 PM   #6
bradgrafelman
Pna lbh ernq guvf?
 
Join Date: Jul 2004
Location: 40.566N -89.731W, ~469ft above sea level
Posts: 11,488
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)

Useful links: Debugging 101 || NJOE || (Sig image) || Rolla Engineered Solutions, LLC
bradgrafelman is offline   Reply With Quote
Old 04-01-2006, 10:09 PM   #7
mister_t101
Learner
 
Join Date: Mar 2006
Location: Long Pond, PA
Posts: 14
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.
mister_t101 is offline   Reply With Quote
Old 04-02-2006, 10:57 AM   #8
Weedpacket
Custom User Title™
 
Weedpacket's Avatar
 
Join Date: Aug 2002
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.
Weedpacket is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 01:46 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.