+ 3
When do you use $_GET
as $_POST is safer and don't display user input in url?
6 Réponses
+ 4
Well, Get is shown in url, if you have seen google or other search engine. They have url of search something like
http://www.example.com/?query=Your_search_data
In some cases you have to show data to user what they have done or doing for better user experience.
Moreover, largest video sharing site is YouTube. When you click on any video it will open a url something like
https://www.youtube.com/watch?v=video_id
and if you see there is a get method. If you not use, yes you can distinguish the data but how your user. How can they share video to other social networking site. When you learn more and know about .htaccess you will understand that there is nothing like watch folder inside youtube website which contain many videos or it use to get video. But it is just a url rewrite to make more understandable the things. it is possible to bookmark the page. This can be useful in some cases.
GET may be used for sending non-sensitive data
wow, I have write a lot.
+ 2
wow thanks for the long answer , i definitely understand it,
so
get is used for user experience purposes such as to share url(for advertising and others) and for user to double check their page(for example in google, user has the ability to change search queries by changing the url(although it's not user friendly)
whereas
by using post , it is used for transferrig sensitive information that you don't want others to have access to by changing url(from GET)
+ 2
if you want what are you send with the action and seen in the URL u must GET . for example pages.
+ 2
We use $_GET method when the details which we enter in the form must be visible in the URL while submitting it.It is considered as insecure since the critical data such as passwords, bank account details etc can be stolen from the URL.
+ 1
$_GET is used to extract data from query string.
Consider this example:
http://www.nowhere.com?name=ricky
In the above query string 'name' is the key and 'ricky' is the value. Now we can use $_GET to get the information in second page like this.
<?php echo $_GET['name'] ?>
Output:
ricky
0
hieu