Jump to content


Photo

One form two actions


  • Please log in to reply
3 replies to this topic

#1 cameeob2003

cameeob2003
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 18 August 2006 - 08:11 AM

I have the following code I am trying to work with:

<form method="post" action="act.php" name="form1">
                <tr>
                  <td><table width="13" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="13"><img src="images/index_15.gif" width="45" height="17" alt=""></td>
						<td><input type="text" name="email" value="" style="background:url(images/index_16.gif); width:139px; height:13px; border:none; font-size:9px;" /></td>
						<td><img src="images/index_17.gif" width="17" height="17" alt=""></td>
                      </tr>
                    </table></td>
                </tr>
                <tr>
                  <td><table width="194" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="185"><img src="images/index_18.gif" width="201" height="5" alt=""></td>
                      </tr>
                    </table></td>
                </tr>
                <tr>
                  <td><table width="188" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="44"><img src="images/index_19.gif" width="50" height="16" alt=""></td>
                        <td width="136"><input type="submit" name="subscribe" value="" style="background:url(images/index_20.gif); width:58px; height:16px; border:none;" /></td>
                        <td width="10"><img src="images/index_21.gif" width="7" height="16" alt=""></td>
                        <td width="17"><input type="submit" name="unsubscribe" value="" style="background:url(images/index_22.gif); width:66px; height:16px; border:none;" /></td>
						<td><img src="images/index_23.gif" width="20" height="16" alt=""></td>
                      
                    </table></td>
                </tr>
				</form>

I want this part:

<form method="post" action="act.php" name="form1">
                <tr>
                  <td><table width="13" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="13"><img src="images/index_15.gif" width="45" height="17" alt=""></td>
						<td><input type="text" name="email" value="" style="background:url(images/index_16.gif); width:139px; height:13px; border:none; font-size:9px;" /></td>
						<td><img src="images/index_17.gif" width="17" height="17" alt=""></td>
                      </tr>
                    </table></td>
                </tr>
                <tr>
                  <td><table width="194" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="185"><img src="images/index_18.gif" width="201" height="5" alt=""></td>
                      </tr>
                    </table></td>
                </tr>
                <tr>
                  <td><table width="188" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="44"><img src="images/index_19.gif" width="50" height="16" alt=""></td>
                        <td width="136"><input type="submit" name="subscribe" value="" style="background:url(images/index_20.gif); width:58px; height:16px; border:none;" onClick="document.theform.action='?act=subscribe';" /></td>

to access one form. While this code:

<td width="17"><input type="submit" name="unsubscribe" value="" style="background:url(images/index_22.gif); width:66px; height:16px; border:none;" onClick="document.theform.action='?act=unsubscribe;" /></td>
						<td><img src="images/index_23.gif" width="20" height="16" alt=""></td>
                      
                    </table></td>
                </tr>
				</form>

Accesses and is processed through another php page upon submition.
I know this can be done through javascript but is there an easier way since I have no knowledge of javascript seeing how I am still learning php. Any help would be great.

Also if I give 2 forms the same name="" value will they submit to the same form and be processed at the same time?

#2 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 18 August 2006 - 08:15 AM

Why not actually have two differant forms?
<form action="page1.php">
All the code for page1 including the submit button
</form>
<form action="page2.php">
All the code for page2 including the submit button
</form>


#3 cameeob2003

cameeob2003
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 18 August 2006 - 08:18 AM

I wanted to do that but it is hard to because it messes up my image layout if I dont place the <form></form> outside of the <tr></tr> tags. I realy need to know If I can wrap each <input> with <form></form> tags individually and set the name the same on 2 of the form tags will it pick up that the 2 forms are meant to be one?

#4 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 18 August 2006 - 08:21 AM

Well it is quite easy if you had all the content on the same page and weren't trying to use two separate php pages, because you can use isset() :

<php
if(isset($_POST['subscribe'])){
//all of the php for subscribing
}
if(isset($_POST['unsubscribe'])){
//all of the php for unsubscribing
}
?>

If it is possible to do that, it will be far easier, otherwise you are going to have to pass all of the form input to the othe php page, either by get or by post using cURL.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users