Jump to content

HTML Form POST


inkubus08

Recommended Posts

I need to find out if there is a way to pass input button values when a form is submitted. I need to submit the form, evaluate the button values, and then using PHP insert them into a MySQL database. I know that the values of hidden buttons are passed using the post or get method but I need the values of all input buttons on the form. Any help would be great. Thanks.

Link to comment
Share on other sites

I can't speak for PHP specifically, but Cold Fusion does pass the button information. I quite often check the value of the form buttons (what ever the "name" attribute is" and base my actions on them.(form page)<cfinput type="submit" name="update" value "update"><cfinput type="submit" name="delete" value "delete">(action page)<cfif ISDEFEINED("form.update")>(update record)<cfelseif ISDEFEINED("form.delete")>(delete record)<cfelse>(no action performed - return to page)</cfif>I imagine the same concept would apply to ASP and PHP - someone else here might help you more specifically. In the meantime, I'd try sniffing for it in a similar way.Hope that helped.

Link to comment
Share on other sites

The same is true for ASP, infact it should be true for all server side code. The form data is passed to the web server in a http request regardless of server side technologies. Cold Fusion, or ASP, or PHP (etc.) will just extract the form fields and their values from the request, it won't really be aware of what's from a button and what's from an input field.So, basically, just put a value attribute on your button like Skemcin says and it should work :)

Link to comment
Share on other sites

Pollux is correct. PHP does not know what type of element it is retrieving info from. But this is how to do it. Beware---the user has to click a submit button for it to work.

<form method="POST" action="the current php page you're on"><input blahblahblah name="daaaa"><input blahblahblah name="LOLOLOL"><input type="submit" value="OMG"></form><?php$da = $_POST['daaaa'];$lol = $_POST['LOLOLOL'];echo $da.$lol;?>

Link to comment
Share on other sites

Thank you for the help but I need to know how to make this work.....Maybe i'm doing something wrong but with this example when the submit button is pressed name/value of the two buttons are not being passed to php....the echo produces nothing....any additional help would be wonderful...<form method="POST" action="whatever the file name is"><input type="button" value="TEMP" name="daaaa"><input type="button" value="TEST" name="LOLOLOL"><input type="submit" value="OMG"></form><?php$da = $_POST['daaaa'];$lol = $_POST['LOLOLOL'];echo $da.$lol;?>I need to have the value of each button available after the form has been submitted.

Link to comment
Share on other sites

Dear inkubus08,With PHP, you cannot pass values from input of type buttons. A button only indicates what should be done. It does not store anything that can be passed. So change your style of coding to some valid input types - checkboxes, radio buttons, etc.Good luck.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...