thedigicraft / Atom.CMS

Atom.CMS
56 stars 52 forks source link

Question regarding $_GET[] and $_POST[] #211

Closed bidjan closed 7 years ago

bidjan commented 7 years ago

Hi Creptor:

I use the following in queries for settings, update works fine:

if(isset($_GET['id'])  != '') {

                $action = 'updated';
                $q = "UPDATE settings SET id = '$_POST[id]', label = '$label', value = '$value' WHERE id = '$_POST[openedid]'";
                $r = mysqli_query($dbc, $q);

            } 

But the following fails to update settings: if(isset($_POST['id']) != '') {

                $action = 'updated';
                $q = "UPDATE settings SET id = '$_POST[id]', label = '$label', value = '$value' WHERE id = '$_POST[openedid]'";
                $r = mysqli_query($dbc, $q);

            } 

Can you explain to me why

Thanks

Bob Ghodsi

creptor commented 7 years ago

There a lot of differences between a POST and GET data sent over to a page....

To start you need to know that the GET data is included in the values of the URL (generates new arrays in it), and the POST sends the information as hidden parameters (hidden partially). Also due to the nature of the URL, the POST is a more effective way to handle form submission.

For more reference check these pages: POST GET HEAD Or this other reference W3schools

creptor commented 7 years ago

Also these links could be helpful https://tools.ietf.org/html/rfc7231#section-4.3.1 https://tools.ietf.org/html/rfc7231#section-4.3.2

bidjan commented 7 years ago

Hi creptor:

Thank you for all your tips. I was able to correct settings form to accept $_POST[]

Bob Ghodsi