Please don't yell, globals off Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Please don't yell, globals off Question

Post by robster »

I'm really sorry all, I've finally started a new site and decided I may not be with my current host forever so it's time to get up and runing with globals off.

I understand that if your <form method="get"> use $_GET.
If your <form method="post"> use $_POST.

What I don't understand is when I use PHP to send a variable like this for instance:

<a href = \"index.php?category=pigs\">link text here</a>

What is the variable 'pigs' sent as? Post or Get?

Thanks fo much and I do apologise for this, I can't believe after all these php years I'm asking this! (but glad to be making the step).
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

as you pass the data in the uri, it will be in $_GET.

meaby time to learn the difference between get and post?

The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. If the Request-URI refers to a data-producing process, it is the produced data which shall be returned as the entity in the response and not the source text of the process, unless that text happens to be the output of the process.


The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line. POST is designed to allow a uniform method to cover the following functions:

- Annotation of existing resources;
- Posting a message to a bulletin board, newsgroup, mailing list,
or similar group of articles;
- Providing a block of data, such as the result of submitting a
form, to a data-handling process;
- Extending a database through an append operation.


read full explanation at http://www.w3.org/Protocols/rfc2616/rfc ... tml#sec9.3
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

robster wrote:What is the variable 'pigs' sent as? Post or Get?
look variable here is 'category' not 'pigs'.
So you will recieve this as --

Code: Select all

$cat = $_GET&#1111;'category']; \\$cat will now contain 'pigs'
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Hey timvw! How come we get to reply to same persons/post at the same time :? :lol:
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

Thank you both, quite informative (both code and concept).

It's really not so hard at all, it's just when you do it X way for so long, Y way becomes more difficult than it should...

:)
Post Reply