form "post" not passing var
programming php in windows.
now have a very basic problem. a simple script will illustrate my problem: contents of exampe.php: <form action="example2.php" method="post"> Name: <input type="text" name="name"><br> <input type="submit" value="accept"> </form> contents of example2.php: <? echo "hello $name"; ?> now, my problem is that example2.php doesn't output $name. it seems like the value of "name" is not stored in $name. anyone knows how to configure/fix this problem? |
I think you need to assign a value to name.
Code:
<input type="text" name="name" value="crabboy"> |
it gets a value when something is typed in the textbox.
|
I pasted your example into a file and it works on my machine.
Code:
// example.php Code:
// example2.php Code:
hello: crabboy |
of course it works!
i know it works..that's not the issue. the problem is that some configuration or something makes it NOT work on MY computer. my question was if anyone knew what could be the cause of this error. |
Try accessing it as:
Code:
$_POST['input_name'] |
Try putting a phpinfo() call after the print in example2.php. Look under the PHP Variables section to see if a _POST["name"] exists. You should also see a ton of other PHP Variables.
|
yeah.
echo "hello $_POST[name]"; works thx |
Turn on the register_globals directive on the php.ini file and you will able to access the variable as $name.
|
Re: form "post" not passing var
Hi niehls
I have the same problem in my server redhat ver 9 You resolve the problem, how? Thanks, OPC +----------------------------------------------------------------- Quote:
|
well, read the posts above and the problem is most probably solved. if register_globals is turned off in your php configuration file you have to either turn it on (not recommended) or use the proper globals assigned to these variables.
access the variable by $_POST["name"] (in my case). turning register globals off is not recommended both because it might cause problems with multiple variables ending up with the same name and it is also a security vulnerability. (people might put &foo=bar in the adress field which will assign your variables other values. hope this helps. otherwise post again. quoting your script would probably help if the problem remains. Cheers |
All times are GMT -5. The time now is 01:30 AM. |