I have two submit buttons in a form. How do I determine which one was hit serverside?
Since you didn't specify what server-side scripting method you're using, I'll give you an example that works for Python, using CherryPy (although it may be useful for other contexts, too):
Rather than using the value to determine which button was pressed, you can use the name (with the tag instead of
). That way, if your buttons happen to have the same text, it won't cause problems. The names of all form items, including buttons, are sent as part of the URL. In CherryPy, each of those is an argument for a method that does the server-side code. So, if your method just has
**kwargs
for its parameter list (instead of tediously typing out every single name of each form item) then you can check to see which button was pressed like this:
if "register" in kwargs:
pass #Do the register code
elif "login" in kwargs:
pass #Do the login code