General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 7th, 2003, 03:35 AM
Alicia Alicia is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 117 Alicia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 29 sec
Reputation Power: 6
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..

Reply With Quote
  #2  
Old October 7th, 2003, 07:51 AM
mattp23 mattp23 is offline
Moderated
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: UK
Posts: 82 mattp23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 43 m 44 sec
Reputation Power: 6
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:
 auth.php:
<?
php 
// define $authorized = true only if user is authenticated 
if (authenticated_user()) { 
   
$authorized true


if (
$authorized) { 
   include 
"/highly/sensitive/data.php"

?> 
In the above example, $authorized was not set to false if the user was not authenticated, thus if auth.php was called with GET auth.php?authorised=1 then $authorised would be true from the begining, so anyone would be authorised. See the php manual's security chapter on Using register_globals for related information. ( http://www.php.net/manual/en/securi...sterglobals.php )

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.

Reply With Quote
  #3  
Old October 7th, 2003, 09:01 AM
mattp23 mattp23 is offline
Moderated
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: UK
Posts: 82 mattp23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 43 m 44 sec
Reputation Power: 6
also see this thread:
Register Globals (How It Works)

Reply With Quote
  #4  
Old October 7th, 2003, 10:00 PM
mwichmann4 mwichmann4 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 81 mwichmann4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 27 sec
Reputation Power: 6
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.

Reply With Quote
  #5  
Old October 11th, 2003, 10:56 PM
manoloweb manoloweb is offline
Moderated
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Monterrey MX
Posts: 49 manoloweb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Re: using $_POST

Quote:
Originally posted by Alicia
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 ???


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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > using $_POST


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT