Jump to content

Recommended Posts

If you are dealing with submitting data from a form I would use the POST method and use $_POST to retrieve the submitted data. 99% of the time. I rarely use the GET method on a form to submit data as the data is showing in the URL which may show personal information, such as passwords etc. POST is more secure as it is hidden and the user can't see what data is being submitted.

The only time I use $_GET is on links when I need to send variables to my script to show different information. When I'm send data over the url I usually only accept certain keywords/numbers to be sent over. Such as if I only want numerical data to be sent over the URL I'll check the data that is being sent is a of a numerical value like so:
[code]<a href="?var=0125698">Send 0125698 over the url</a> | <a href="?var=hello">Send hello over the url</a>
<hr />
<?php

if(isset($_GET['var']) && is_numeric($_GET['var']))
{
    echo "Var is number!";
}
else
{
    die("<b>Script Terminated</b> - No/Invalid data being sent!");
}

?>[/code]When you run the script the first time it'll display:
[b]Script Terminated[/b] - No/Invalid data being sent!

Untill you click the first link. When you click the secound link it'll show the above message.

You should always validate any user input from any user as you don't know who is sending what to your page. The same applies to $_POST too.
Link to comment
https://forums.phpfreaks.com/topic/7465-_get-or-_post/#findComment-27194
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.