I see most everyone uses:
$date = $_POST['date'] ;
But this also works too:
$_POST['date'] ;
Why use the first when the second seems to do the same thing?
| SitePoint Sponsor |



I see most everyone uses:
$date = $_POST['date'] ;
But this also works too:
$_POST['date'] ;
Why use the first when the second seems to do the same thing?
Opportunity favors the prepared mind.



Copying the post variable 'date' to a local variable. Can make it easier to type to or to do future processing on it. Hardly makes a difference.
If there's any legacy code in an app that requires register_globals on this could also be used to get round that.
As Will says + if you decide to use GET or the date arrives by some other method ( from db etc ) at some point in the future you only have one change to make.
and what is the difference between post and get please?




post = submitted from within the browser
get = submitted through the URL
sessions = stored on the server
cookies = stored on the client
i will search more about that :-) thanks for your short and sweet info


Also the advantage of registering 'simple' variables from the different globals is that you can do all processing, error checking etc once and not each time you use it eg:
Instead ofPHP Code:# this as an example.....
$date= stripslashes(htmlentities(trim($_POST['date'])));
# could then be used
echo $date;
mysql_query("select * from table where '$date' = date");
MikePHP Code:$date= stripslashes(htmlentities(trim($_POST['date'])));
# could then be used
echo stripslashes(htmlentities(trim($_POST['date'])));
mysql_query("select * from table where '". mysql_real_escape_string($_POST['date'] . "' = date");
#etc.....
Mike Swiffin - Community Team Leader
Only a woman can read between the lines of a one word answer.....
I started out with nothing... and still got most of it left!
Bookmarks