Page 1 of 1
new to PHP .....
Posted: Sun Apr 28, 2002 7:31 am
by mzfp
im absolitely new to PHP, and have set it up on my local computer to run with Apache as an SAPI module. Everything works fine, except when processing a form, the page that is loaded to deal with the form data, doesnt seem to be aware of the form values
eg a input names name in my form, should be accessed on my php page as $name, but this doesnt print out any value.
This is only the case on my computer, when i upload it to my server, which allows PHP scrpting, it works fine.
Any suggestions, maybe i havnt installed some modules? if so how do i install them, and which ones?
thanks
M[/b]
Posted: Sun Apr 28, 2002 7:44 am
by jason
Instead of $name, use $_GET['name'] or $_POST['name'].
$_GET if you are passing the values by the get method, or $_POST if you are passing by the post method.
Let me know if it works, and I will tell you why. =)
it wrked ! :-D
Posted: Sun Apr 28, 2002 7:52 am
by mzfp
thanks mate, it worked, and u saved me alot of time crawling round the web looking for a solution! .. so why does it work is the nex natural question!
Posted: Sun Apr 28, 2002 8:00 am
by jason
Because, as you mentioned, you are new, and that would mean you just installed PHP 4.2.
If you read on this page:
http://www.php.net/release_4_2_0.php
This part:
External variables (from the environment, the HTTP request, cookies or the web server) are no longer registered as global variables
This is where your problem occured.
You were attempting to access a variable from a Get or Post method, or an external variable (Sessions, Cookies, and such also fall into this category) directly, as a global.
For security purposes, these are disabled. However, you can change that.
All you have to do is edit the php.ini file.
Look for this line:
And switch it with this:
Now, I would recommend doing that, however, I also urge you to use $_GET and $_POST over directly accessing the variable like you were. This is for security reasons and what not.
You can read more about that and the reasons here:
http://www.phpadvisory.com/articles/view.phtml?ID=1
Good luck
