[Quick Reminder]Multiple submit buttons in the same HTML form

The trick us, use the same name but different values on the button.
For example, if we wanted to have both ‘Submit’ and ‘Cancel’ in the same form.

<form action=’blah.foo’ method=’post‘>
<input type=’text‘ name=’blah‘ />
<button name=’actionvalue=’submit‘>Submit</button>
<button name=’actionvalue=’cancel‘>Remove</button>
</form>

So now, in whatever language we use to treat the post request, we could simply read the posted data from these buttons


For example, in PHP

$action = $_POST[‘action’];

if ($action == ‘submit’)
{

}

else if ($action == ‘cancel’)
{

}


or in ASP.net
string action = Request.Form[“action”];
switch (action)
{
case “submit”:
break;
case “cancel”:
break;
case “default”:
break;
}

That’s why I need to start this blog…..I forgot how to get POST from ASP.net now. Something like Request.QueryString….?

People are doing more complex things now it’s taking on average more clicks to find these fundamental references