Jump to content

How Do I Get The Value Of A Button Using Php


Recommended Posts

if the form sent with method='get' then all the data will be available in $_GET asscociative superglobal array if method='post' it will be in $_POST asscociative superglobal array.

Edited by birbal
Link to post
Share on other sites

and , you may like to post your question in appropiate forum so that more of related people will be able answer your question

Link to post
Share on other sites

I will try to post in the appropriate forums from now on. I am using Post but it will not work. Here is the code and it is not returning the value of the button. Why wont it return the value "commando" with the data that the user populates. HTML code <html><body><form action="form_lessons_post_process.php" method="post">Name: <input type="text" name="fname" />Age: <input type="text" name="age" /><input type="button" name="test" value="commando" /><input type="submit" /></form></body></html> PHP code <html><body><?php echo $_POST["fname"]; ?><br /><?php echo $_POST["age"]; ?><br /><?php echo $_POST["test"]; ?><br /></body></html>

Link to post
Share on other sites

This: <input type="button" name="test" value="commando" /> you have as type="button". The type button usually is associated with JavaScript; where you assign a function to that button. When it's clicked on, whatever you wrote for the function to do, it will do. That's basically what the "onclick" command is all about when it comes to an HTML element.

Link to post
Share on other sites

The values of buttons inside a form do not get submitted with the form data. The only button value which gets submitted is the value of the submit button you clicked on, as long as the button has a name. You need to use something other than a button, like a hidden field.

Link to post
Share on other sites

This has already been discussed, in a duplicate topichttp://w3schools.inv...view=getnewpost Which now seems to have been removed completely? instead of merged. last post

confused and dazed has just posted a reply to a topic that you have subscribed to titled "How Do I Get The Value Of A Button Using Php".----------------------------------------------------------------------I ended up writing a function called placevalue and I used scorewinner and placevalue all on the same onclick operator and it worked!!! Thanks for your help. It was a big step forward for me. I think I am starting to understand a few things. function placevalue(teamvalue, newteamvalue){newteamvalue.value = teamvalue.value}----------------------------------------------------------------------The topic can be found here: http://w3schools.invisionzone.com/index.php?showtopic=40676&view=getnewpost
Edited by dsonesuk
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...