0

I think this is simple.very. but i think i am missing something. I have a link:

 website.com/page?variable=value

when i use $_GET["variable"] i get the value, but when i use $_POST["variable"] , i dont get the value? Please Help.

infused
  • 24,000
  • 13
  • 68
  • 78
  • 2
    That's because you're sending the values using the `GET` method. If you want to use `POST` method, create an HTML form and let the user submit it (or use AJAX to do the `POST`). Then you'll be able to access it with `$_POST`. – Amal Murali Apr 16 '14 at 16:35
  • @AmalMurali its a link to a profile of a person. i dont want people to fill up the name of the person everytime they want to open his page. – Saurav Chaudhary Apr 16 '14 at 16:37
  • Then why do you want to use `$_POST` in the first place? – Amal Murali Apr 16 '14 at 16:38
  • i dont want the question mark and the variable value. doesn't look cool. – Saurav Chaudhary Apr 16 '14 at 16:40
  • @SauravChaudhary `i dont want the question mark and the variable value`, then use `POST`! i dont understand what the problem is.. – celeriko Apr 16 '14 at 16:43
  • @SauravChaudhary: You can use `.htaccess` to prettify the links. But before you do anything, I suggest you learn the basics of HTML. This is a good starting point: http://htmldog.com/ – Amal Murali Apr 16 '14 at 16:45

1 Answers1

3

This is normal behaviour.

$_GET is populated with data from the URL's query string (which is taken from the request's headers).

$_POST is populated with data from the request's body.

If you want to read data from the URL's query string, use $_GET.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335