inkubus08 Posted February 27, 2006 Share Posted February 27, 2006 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 with the post....the echo produces nothing...is there a way to make this scenerio work???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 More sharing options...
ThePsion5 Posted February 27, 2006 Share Posted February 27, 2006 I assume the form action is the name of the file with the form in it? If not, that could trip you up. Aside from that i'm not sure what could be causing the problem... Link to comment Share on other sites More sharing options...
inkubus08 Posted February 27, 2006 Author Share Posted February 27, 2006 yes...for example if the file named test.php the form would be:<form method="POST" action="test.php"><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;?>if this will not work would anyone see a another way that i could get the values from the buttons so that i can add the values to a mysql database.....normally i would process the form like above and then store the values as php variables and then use php to add them to my database... Link to comment Share on other sites More sharing options...
DarkElf Posted February 27, 2006 Share Posted February 27, 2006 Does php give you an error message? If so that might be useful.What it might be is that because the user only presses one of the buttons maybe only one of the values will be posted (I could be wrong, it's just a theory). If this is the case then maybe it gets iffy when you try echoing both values and only one exists.Alternatively it might be a syntax issue. There are 3 different ways of accessing post variables. $_POST['daaaa'] is the medium form, there is also long form which is $HTTP_POST_VARS['daaaa'], and short form in which the post variables are automatically assigned their previous name so you could just use $daaaa (php assigns the variable for you without you having to do it). Which forms are allowed is determined by your php administrator and the version of php in use, it should be listed somewhere in the stuff spurted out by the phpinfo() function. Try using the different syntaxes. Note that the long form is being depricated in the next version of php.Another thing it might be having quibles with is that you are sending information to the same page. This shouldn't be a problem, but try and see if it works putting the php on another page and posting to that page? Link to comment Share on other sites More sharing options...
gsmith Posted February 27, 2006 Share Posted February 27, 2006 just to clarrify...this part:<?php$da = $_POST['daaaa'];$lol = $_POST['LOLOLOL'];echo $da.$lol;?>is in the other file, named test.php correct? Link to comment Share on other sites More sharing options...
DarkElf Posted February 27, 2006 Share Posted February 27, 2006 Furthering my previous post - a different syntax issue could be that you've not bracketted the variables after the echo statement e.g. echo ($da.$lol). As echo isn't technically a php "function" (for reasons I don't fully understand but am assured are correct) this shouldn't matter though. Link to comment Share on other sites More sharing options...
inkubus08 Posted February 27, 2006 Author Share Posted February 27, 2006 this doesn't work eitherTest.php<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body><form method="POST" action="temp.php"><input type="button" value="TEMP" name="daaaa"><input type="button" value="TEST" name="LOLOLOL"><input type="submit" value="OMG"></form></body></html>Temp.PHP<?php //temp.php$da = $_POST['daaaa'];$lol = $HTTP_POST_VARS['LOLOLOL'];echo $da;echo ($lol);?> Link to comment Share on other sites More sharing options...
gsmith Posted February 27, 2006 Share Posted February 27, 2006 is your PHP file called temp.php or Temp.php? Letter case would matter. Link to comment Share on other sites More sharing options...
inkubus08 Posted February 27, 2006 Author Share Posted February 27, 2006 sorry for the confusion...the file names are correct because it does load the php file just nothing is displayed....if i another echo to temp.php it displays...for example:<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 'This is a test.';echo $da.$lol;?>when submit is press this is displayed:This is a test. Link to comment Share on other sites More sharing options...
gsmith Posted February 27, 2006 Share Posted February 27, 2006 I think your problem might be the buttons.If I change your two buttons to text fields, it works for me. Link to comment Share on other sites More sharing options...
inkubus08 Posted February 27, 2006 Author Share Posted February 27, 2006 Thats the point.....POST method works for text fields....radio buttons....hidden buttons...etc...but not for regular buttons...i need to know how to process the regular buttons as if they were text fields/hidden buttons/radio buttons (if that makes sense) Link to comment Share on other sites More sharing options...
homoeopathy80 Posted March 2, 2006 Share Posted March 2, 2006 Why not just use radio buttons instead of regular buttons? Same effect, right? Thats the point.....POST method works for text fields....radio buttons....hidden buttons...etc...but not for regular buttons...i need to know how to process the regular buttons as if they were text fields/hidden buttons/radio buttons (if that makes sense)<{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now