Hey guys I am a newbie in PHP and programming all together. Can anyone tell me the difference between Get andPOST methods of PHP. and also which one is better and in wat advantages each of them has.
thanks for your help...
thanks for your help...
| Code: |
| <form method="post" action="somepage.php">
<input name="username" /> <input name="password" /> </form> |
| Code: |
| $_POST[username]
$_POST[password] |
| Code: |
| <form method="get" action="somepage.php">
<input name="username" /> <input name="password" /> </form> |
| Code: |
| $_GET[username]
$_GET[password] |
| Code: |
| http://www.yourwebsite.com/users/?id=1 |
| Code: |
| SELECT * FROM site_users WHERE id='$_GET[id]' LIMIT 1 |
| Code: |
| http://www.yourwebsite.com/users/?id=1 |
| Code: |
| $id = (int)$_GET[id]; |
| Code: |
| SELECT * FROM `site_users` WHERE `id` = '" . $id . "' LIMIT 1 |
| phpc0d3r wrote: | ||||
| If you're using a form to login, do not use "GET"! This is dangerous and can leave code open to hackers. Use the "POST" method and some type of sql injection function (protects your code from hackers).
If you only want to show a mysql record that doesn't require user input you can use "GET". You should still use a sql injection function. Example:
|