PHP question regarding multiple submit buttons

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

PHP question regarding multiple submit buttons

Post by amir »

Burrito | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have a form that adds a product into a user's cart.

Let's say it's this:

Code: Select all

<form action=cart.php>

</form>
In the form, there is a size and color of the product, which the user selects, as well as the product id, which is a hidden field, like this:

Code: Select all

<form action=cart.php>

<select name="size" id="size">
  <option value="4x">4x</option>
  <option value="5x">5x</option>
  <option value="6x">6x</option>
</select>

<select name="color" id="color">
   <option value="red">red</option>
<option value="blue">blue</option>
</select>

<input type="submit" name="Submit" value="Add to Cart">
</form>
Now - the trick is, I have to add another button that adds the product to a wish list instead of the cart - in other words, this button will have to pick up the values of the color and size, but then once it hits the cart.php, cart.php needs to know that this button was clicked and it should redirect the user to the wish list coded page with the proper values for the size and color.

Is there a simple way of doing this or am I deluding myself? Also, I put it under php rather than javascript because I would love to do this with php - but if there is some javascript that has to be added I am fine with that as well.

Thanks so much in advance for any help!


Burrito | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

name the two submit buttons the same thing, but give them different values... whichever one was clicked will be the value of that input element.

Also... you've been here a while, you should know to use the correct syntax tags when posting code here. :evil:
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Post by amir »

Thank you Sir!
Post Reply