|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
using $_POST
Hi guys,
I have a doubt here,, hope somebody could help me.. I seen some people use $_POST['name'] to capture the input from a form(method = post)... but most of the time, i just capture the input by using $name... without putting the $_POST... and i dun see any prob with it... does it make any difference if i put $_POST.. it is used only for session purpose or there is certain purposes that i would have to explore ??? please advise.. |
|
#2
|
|||
|
|||
|
It all depends on how your php is set up, depending on your register_globals setting (in php.ini)
Pre php4.2.0 this setting was ON as default, This ment Environment, GET, POST, Cookie and Server variables were registered as global variables. I.E. you could use $name to access $_POST['name']. From php4.2.0 register_globals is turned OFF by default. This means on newer setups $name will not work, but $_POST['name'] will. So for your current php setup your code will work fine, but it would not work on a lot of servers. The default setting of register_globals was changed mainly for security reasons, for example for the following code (lifted from the php manual) PHP Code:
For these reasons it is porbably best to get used to typing $_POST['name'], this will allow better portability (if you move web host, give someone you script / sell your script) stop annoying little errors and imporve security. There are more ways to improve portability for example use <?php ?> insetead of <? ?> or <% %>. There should be an article on imporiving portability someware, look at http://www.devarticles.com/art/1/65 for example. Hope this clears up a few matters. |
|
#3
|
|||
|
|||
|
also see this thread:
Register Globals (How It Works) |
|
#4
|
|||
|
|||
|
its always a good idea to use $_POST though. If you have a long script it could get tricky to remember what these vars are holding.
When i assign a value that is coming from a form the $_POST helps me remember ahh this is coming from a form. Also my comments help me remember too. |
|
#5
|
|||
|
|||
|
Re: using $_POST
Quote:
If you don't specify where the data should come from, you allow people to "play" with your variables from the querystring when you assume that they are from a "form" or the other way... ![]()
__________________
The deal is not to know everything, but to know the email of the one who does. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > using $_POST |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|