Current location: Hot Scripts Forums » Programming Languages » PHP » HELP!! Multiple forms on one page???


HELP!! Multiple forms on one page???

Reply
  #1 (permalink)  
Old 06-30-04, 09:53 AM
tcooper tcooper is offline
Newbie Coder
 
Join Date: Nov 2003
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Question HELP!! Multiple forms on one page???

I want to have multiple forms on one page, however, I need to get the results of the form and keep those results for the remainder of the session. How do I do this? Right now I am just testing this which is why there is not much information on the page. When I select an item in my first box and hit the "Submit" button it works fine. The problem is when I click the "submit" button on one of other forms...I loose all my information. Any help will be greatly appreciated.
PHP Code:

<?php require_once('Connections/Thor.php'); ?>

<?php
function get_ind_string($idx){ //This function will return the string value from my select box
switch ($idx) {
    case 
"2":
        return 
'Electric';
        break;
    case 
"4":
        return 
'IT';
        break;
    case 
"6":
        return 
'Nat Gas';
        break;
    case 
"7":
        return 
'Other';
        break;
    case 
"8":
        return 
'Telecom';
        break;
    case 
"9":
        return 
'Wtr & WasteWtr';
        break;}}
        
?>



<?php
$ckSubmit
=$_POST['ckSubmit']+1;//Here I am declaring variables that occur after the form has been posted
$ckSubmit1=$_POST['ckSubmit1']+1;
$ckSubmit2=$_POST['ckSubmit2']+1;
echo 
$ckSubmit;
echo 
$ckSubmit1;
echo 
$ckSubmit2;

if(
$ckSubmit>1){ 
    
$industry $_POST['selectIndustry'];
    
$ind get_ind_string($industry);}



?>


<html>
<head>
<title>PROJECT OPENING REPORT</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<table width="631" height="143" border="0">
  <tr> 
    <td width="332" height="137"><img src="intranet_01.jpg" name="Image1" width="300" height="50" id="Image1"><img src="intranet_03.jpg" name="Image2" width="300" height="50" id="Image2"></td>
    <td width="283"> <div align="center">
        <p><strong><font size="5">Project Opening Report</font></strong></p>
        <p>
          <input type="text" value="INDICATES REQUIRED FIELDS" style="width:80%; background:yellow" name="textfield">
        </p>
      </div></td>
  </tr>
</table>
<form name="form1" method="POST"  action="<?php echo $_SERVER['PHP_SELF']?>">

<input type="hidden" name="ckSubmit" value="<?php echo $ckSubmit?> ">

            <?php      if ($ckSubmit<2) {?>
            <select name="selectIndustry" style="width:20%; background:yellow" size="1" id="selectIndustry">
              <option value="2">Electric</option>
              <option value="4">IT</option>
              <option value="6">Natural Gas</option>
              <option value="7">Other</option>
              <option value="8">Telecom</option>
              <option value="9">Wtr &amp; WasteWtr</option>
            </select>
            <?php      } else {?>
            <input name="txtSelectIndustry" type="text" id="txtSelectIndustry" value="<?php echo $ind$ckSubmit=3?>">
            <?php }?>
<input type="submit" name="Submit" value="Submit" >
</form>

<form name="form2" method="POST"  action="<?php echo 

$_SERVER['PHP_SELF'];?>">
<input type="hidden" name="ckSubmit1" value="<?php echo $ckSubmit1?> ">


<input type="submit" name="Submit" value="Submit">
</form>

<form name="form3" method="POST"  action="<?php echo $_SERVER['PHP_SELF'];?>">
<input type="hidden" name="ckSubmit2" value="<?php echo $ckSubmit2?> ">


<input type="submit" name="Submit" value="Submit">
</form>
<p>&nbsp;</p>
</body>
</html>

Last edited by Nico; 07-25-07 at 09:08 AM.
Reply With Quote
  #2 (permalink)  
Old 06-30-04, 12:58 PM
infinitylimit's Avatar
infinitylimit infinitylimit is offline
Code Guru
 
Join Date: Jun 2004
Location: Oregon
Posts: 758
Thanks: 0
Thanked 0 Times in 0 Posts
I'm not sure you are going about this the right way. What are you trying to do, it looks like you are trying to do some type of vote or selection... I don't think you need to use multiple forms.
__________________
Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
Reply With Quote
  #3 (permalink)  
Old 06-30-04, 01:19 PM
tcooper tcooper is offline
Newbie Coder
 
Join Date: Nov 2003
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
This is just a very small sample of what I am trying to do. I have several pieces on my form that are submitted at different times so I can pull off the variables. Right now a person has to fill out the form in order or it will not submit properly. I am trying to work around that and thought if I had multiple forms it would solve my problem, however, as you can see from my previous post, that is not working either.
Reply With Quote
  #4 (permalink)  
Old 07-03-04, 05:03 AM
mikaelf mikaelf is offline
Wannabe Coder
 
Join Date: Jun 2004
Location: php[dot]net
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
yeah, of course. there will be only one concurrent superglobal $_POST for each post action taken from the each form. i propose to save the variables in superglobal $_SESSION or databases or whatever you want it to in order to keep them in the multiple forms.
Reply With Quote
  #5 (permalink)  
Old 07-03-04, 03:49 PM
infinitylimit's Avatar
infinitylimit infinitylimit is offline
Code Guru
 
Join Date: Jun 2004
Location: Oregon
Posts: 758
Thanks: 0
Thanked 0 Times in 0 Posts
saving them in $_SESSION would work, it will just take alot of memory and if you plan on having a bunch of people using it the same time it might causing SESSION fragmentation.
__________________
Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
Reply With Quote
  #6 (permalink)  
Old 07-03-04, 08:59 PM
Infinite_Hackers's Avatar
Infinite_Hackers Infinite_Hackers is offline
Coding Addict
 
Join Date: Dec 2003
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Wouldn't just using $HTTP_POST_VARS do it? if you don't need it in 1 form just make it as a hidden input, and you can do that for ever form, that way the information is passed on.
__________________
New beta project: GFX-PRO.ATH.CX
Description: GFX-PRO a great new project that anyone can and setup in less then a minute. [ More info ]
Website: http://gfx-pro.ath.cx
Status: Online
http://gfx-pro.ath.cx/sig.png
Reply With Quote
Reply

Bookmarks


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

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Classified Ads skipper23 Perl 3 11-22-05 02:22 AM
Paginating problem,extra empty page morrowind PHP 2 05-03-04 03:32 AM
GOING INSANE! - iFrames, Javascript (swap images) & Forms? gem JavaScript 4 04-19-04 04:54 AM
page browsing problem mivec PHP 3 04-17-04 03:43 AM
Classified Ads skipper23 Perl 2 12-30-03 03:43 AM


All times are GMT -5. The time now is 05:07 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.