I haven't officially started learning PHP, just skimming through a couple tutorials and I have a question. Why would some one choose to use Get vs Post? Why would you ever want the data shown in the url bar? I understand post is used for passwords and important info but I don't understand why you would use get instead of just post all the time?
Thanks for any insight.
$_GET
is useful for pages where users are requesting data - such as a search page, and pages that a user might want to bookmark and share with others. Actions that should be readonly.
$_POST
is useful for pages where users are "posting" data - such as a signup form. $_POST
should be used when you don't want your visitors to be able to bookmark page. Actions that write data.
As prodigitalson added: you may use $_POST
or $_GET
for any operation, but it is good practice to use them as described above.
If you want people to be able to share the link with their friends...for eg http://example.com/products.php?product_id=12
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With