Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find source of form submit click

Status
Not open for further replies.

ShamaJamms

Programmer
Mar 28, 2007
11
I'm looking for a way to find the source of a form submit button click. On the page, I have 2 different <form> elements with 2 different names, serving 2 different objectives. But they are both parsed by the same PHP code, but I need it to figure out if the Withdraw button was clicked, or the Deposit button was clicked.

How would I do this?
 
Inspect your $_POST (or $_GET, depending on form posting method) array on the receiving page and see how your buttons have been carried over. Make sure you test that in different browsers, because sometimes browsers send button information differently. When you have found out what most browsers do, you will be able to put a simple if function to check which button was pressed.
 
Make use of name and value tags of submit button element.
Code:
<form>
...
<input type="submit" name="submit" value="Withdraw">
..
</form ..method="POST">
...
<form..method="POST">
...
<input type="submit" name="submit" value="Deposit">
..
</form>
Your PHP code should be
Code:
if ( $_POST["submit"] == "Withdraw" )
{
// code for withdraw
..
}

if ( $_POST["submit"] == "Deposit" )
{
// code for Deposit
..
}


--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top