Jump to content

Form Processing


inkubus08
 Share

Recommended Posts

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

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

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

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

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

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

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)

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
 Share

×
×
  • Create New...