-1

I learned about PHP request methods and til now, I thought I knew at least some of them like POST and GET, but then I encountered codes using both of them for requesting primary keys.

I googled and searched SO but weirdly found nothing that explained the logic behind which method to choose in various scenarios; and the one more specifically I'm curious to know about here is which one to use for requesting primary keys? TYIA.

gskema
  • 3,141
  • 2
  • 20
  • 39
Simon.B
  • 70
  • 1
  • 8
  • 1
    Possible duplicate of [What is the difference between POST and GET?](https://stackoverflow.com/questions/3477333/what-is-the-difference-between-post-and-get) – Alon Eitan Feb 21 '18 at 06:47
  • 1
    _"I googled and searched SO but weirdly found nothing"_ - Really? I did a quick search and found _many_ articles about this in a couple of seconds. – M. Eriksson Feb 21 '18 at 06:47
  • 2
    Possible duplicate of [When do you use POST and when do you use GET?](https://stackoverflow.com/questions/46585/when-do-you-use-post-and-when-do-you-use-get) – M. Eriksson Feb 21 '18 at 06:47
  • OMG! May I know what you guys wrote in the search bar? – Simon.B Feb 21 '18 at 06:50
  • `difference php post get` ? – Scriptman Feb 21 '18 at 06:53
  • I just googled `POST GET` - But there are more, and you can read about it [here](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods) – Alon Eitan Feb 21 '18 at 06:56
  • @Scriptman I exactly copied and pasted this in my SO and Google search bar and these result didn't appear! Thanks anyways. – Simon.B Feb 21 '18 at 06:58
  • I wrote `post vs get`. You should read [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) – M. Eriksson Feb 21 '18 at 07:19
  • _"but then I encountered codes using both of them for requesting primary keys"_ - How are we suppose to be able to answer what some developer did somewhere? – M. Eriksson Feb 21 '18 at 07:25

1 Answers1

0

GET Method: When we want to process small amount of the data or else we don't have secure values in data like password and card details etc we will simply use the Get Method of Php.

POST Method: If we want to process large amount of data in form request and that data contain secure information then we will use Post Method of Php.

PUT Method: If we want to update the data then we will use Put method.

Patch Method: If we want to update the data then we will use Patch method.

Delete Method: If we want to delete some data then we will use Delete method.

For Detail let's have a look on below link Thanks

When do you use POST and when do you use GET?

Anil Kumar Sahu
  • 567
  • 2
  • 7
  • 27
  • Sorry but I've specifically asked about primary keys and you've talked nothing about it! – Simon.B Feb 21 '18 at 06:59
  • @Simon.B request methods have nothing to do with primary keys, which usually belong to data bases!? Where did you see the relation between the two? – xander Feb 21 '18 at 07:01
  • @xander Okay, let me explain a bit more. AFAIK you can either write a url string, for example in a form, in a way that contains some primary keys(like id) so that you can use GET method in another PHP script to request it from the server and do some operations with it, or you can send it using the POST method. More precisely, I don't know the reason one might want to use the latter one..., okay? – Simon.B Feb 21 '18 at 07:06
  • @Simon.B In most situations it's up to the developer what to use, in general I like to use GET-requests for data queries (SELECT) and POST-requests to modify data. And you can even use a DELETE-request when deleting stuff but usually also POST is used for that. – xander Feb 21 '18 at 07:13
  • _"...and that data contain **secure information** then we will use Post Method of Php"_ -LOL – Alon Eitan Feb 21 '18 at 10:53