user502019
user502019

Reputation: 49

Using $_GET in a PHP file to display appropriate content

How do you use $_GET and when do you use $_GET? What exactly does $_GET do? I know it is important to use if I want to display user-based content.

Upvotes: 1

Views: 467

Answers (5)

AjayR
AjayR

Reputation: 4179

$_GET is for getting the request parameters when URL/form is submitted, normally shows the values in the URL.

For large/secure data, you should use $_POST collection, where the form method must be "POST". Also you can use $_REQUEST collection which can be GET or POST collections combinations.

Upvotes: 0

trentr
trentr

Reputation: 157

$_GET variables are passed in the URL bar. For example: http://site.com/index.php?var=infohere $_POST are not shown in the URL bar. Pretty much $_POST are a little bit more difficult to see.

More info here: http://www.tizag.com/phpT/postget.php

Upvotes: -1

Mark Grey
Mark Grey

Reputation: 10257

The $_GET and $_POST superglobals can be used to fetch information that was passed in the HTTP request following either of these protocols respectively.

$_GET data will be passed in the url as part of a query string, where as $_POST data will be embedded in the request itself.

You can use these arrays for form submissions, web service calls or any other request that would send parameters.

To read about the other superglobals: http://www.php.net/manual/en/language.variables.superglobals.php

Good luck learning.

Upvotes: 3

Cheruiyot Felix
Cheruiyot Felix

Reputation: 1597

Get is used to carry data to the sever and around the script. It can be used when posting data in forms or in links.

<form action="someactions" method="GET"></form>

or in links as

http://mylink.com/id="200"

use get to obtain the id
$id=$_GET['id'];
echo $id; //Returns 200 value of id

Google to find more on use of get. Note: Get is discouraged compared to post because of its security issues. It displays your content in the url.Use post where you can

Upvotes: -1

user557846
user557846

Reputation:

please refer such questions to the manual:

$_GET

Upvotes: 1

Related Questions