+ 2

How do I apply GET/POST in real life?

I'm struggling with the application of get and post. I understand their differences, but when do I use get? From what I read and researched, I'd just use post to be on the safe side. The only example I kinda understand is with the credit card and it's CV2 number. You would use get with the credit card number and expiration date but post with the CV2 number. Right? Can someone explains this in terms of someone ordering a pizza? When would you use get, when would you use post? Edit: let me be more specific.....you know how you create profiles to make ordering faster in the future and put your address in? Is that the get method used to store and recall that information every time you log in or is that a completely different concept?

8th Aug 2019, 2:23 AM
Toia Richardson
6 Respostas
+ 4
Ya I wouldn't recommend using GET when you're handling sensitive data such as credit card information and no you shouldn't use POST for all request as it's not idempotent, where browser will warn you if you send the request twice which isn't user friendly.(GET method will keep on sending the request until a success response is received which is better at displaying information to users) While POST method is a non idempotent request and the state of the server will be different before and after the request. The browser would warn you if you're trying to resubmit the form/refresh the page and send the data again. This is great because Login forms authentication are also non idempotent. One request per http semantics.
8th Aug 2019, 4:04 AM
Leon lit
Leon lit - avatar
+ 4
Base on your example: When an employee receive a delivery order they would use GET to receive the information from their server and when a consumer use the pizza shop website/app to order a cheese pizza from them, the delivery order information will be transferred from the ordering form to the server through POST method and stored in the database of the company. Hope this help by the way .....
8th Aug 2019, 4:05 AM
Leon lit
Leon lit - avatar
+ 2
Well, a pizza customers profile data are also very important because it contains user data such as their order history, favorite pizza type, how often s/he order pizza and much much more. So the security level need to be as high as possible because they might get sued if their customer data got breached ~_~.(while online bank accounts have a higher security level compared to other services account)
8th Aug 2019, 6:36 AM
Leon lit
Leon lit - avatar
+ 1
Use Node.js or other framework for backend instead of PHP.
8th Aug 2019, 3:58 AM
Gordon
Gordon - avatar
+ 1
I feel you Leon lit. It makes sense now. Thanks! It would be annoying if you got a refresh warning while signing up for a pizza profile versus a bank account.
8th Aug 2019, 5:07 AM
Toia Richardson
+ 1
Always use Post...it is more secure AFAIK 😗
9th Aug 2019, 2:56 PM
Sanjay Kamath
Sanjay Kamath - avatar