Re: [PHP] Form variables not working
On Sunday 17 November 2002 00:36, Chris Jackson wrote: > I am havein troubles gettin my form variables to work. > The "register_globals" in php.ini is set to its default of "off". [snip] > the dosent print anything in the action of the > form and the Because register globals is disabled you have to use $_SERVER['PHP_SELF'], that's covered in the manual. > echo $_POST["answered"]; on the first run gives an error that says that > "answered" is > an undefined variable. That's because the first time you run it you have not submitted a form yet so it's undefined. Various ways to get around this, most straight forward (IMO) being: if (isset($_post['answered'])) { echo $_post['answered']; } -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* This is a test of the emergency broadcast system. Had there been an actual emergency, then you would no longer be here. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form variables not working
At 17:36 16.11.2002, Chris Jackson said: [snip] >I am havein troubles gettin my form variables to work. >The "register_globals" in php.ini is set to its default of "off". > >the dosent print anything in the action of the form That's because register_globals is off :) The PHP_SELF value is contained in the $_SERVER superglobal array and you may access it anytime, everywhere as $_SERVER['PHP_SELF']. >and the >echo $_POST["answered"]; on the first run gives an error that says that >"answered" is >an undefined variable. but on the second submit this error is gone with the >submitted data >displaying correctly. This is not an error you see but a Notice or Warning that you are using a variable (or an array index) that has not been defined yet. While this is not necessary in this siziation it might point out a possible source of problems under other circumstances, allowing you to spot why your script doesn't work as expected. You could either if (array_key_exists('answered', $_POST)) to avoid the warning, or error_reporting(E_ALL & ~(E_NOTICE|E_WARNING)) to switch off notices or warnings for this script, if you are prepared to do so... >Im an experianced ASP developer and im getting frustrated with PHP. why is >it so dificult >to do the simplest things in php? It's not difficult at all, it's just slightly different to ASP. You'll love PHP, promised... -- >O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form variables not working
Because it isn't? Instead of echoing $PHP_SELF, echo $_SERVER['PHP_SELF']. With the $_POST problem, it's complaining that you're using a variable that isn't defined. Use? if(array_key_exists('formfieldnamegoeshere',$_POST)){ print $_POST['formfieldnamegoeshere']; } ?> Chris Jackson wrote: Im an experianced ASP developer and im getting frustrated with PHP. why is it so dificult to do the simplest things in php? thanks -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Form variables not working
I am havein troubles gettin my form variables to work. The "register_globals" in php.ini is set to its default of "off". code: Form Series - Example One asdasdasddassad the dosent print anything in the action of the form and the echo $_POST["answered"]; on the first run gives an error that says that "answered" is an undefined variable. but on the second submit this error is gone with the submitted data displaying correctly. Im an experianced ASP developer and im getting frustrated with PHP. why is it so dificult to do the simplest things in php? please help with simple forms in php that is configured by default to have "register_globals" set to off. thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php