POST, GET

Let's look at what POST and GET are for running the PHP registration page we created earlier.

POST

It passes the selection of each control(input box and button) used in the tag to the url specified in the action.
In this case, the name attribute value used in the input box or the button is used as the variable name, and the value input by the user in the form or the value attribute value used in the button is transferred as the variable value.
Data is unlimited in length and strong in security.

GET

The URL address specified in the action is prefixed with? and the variable name and value are paired to deliver the desired information.
If there are multiple variables, they are separated by &. The GET method is used to simply pass a desired value through a variable, and has a disadvantage in that the value delivered to the address bar of a web browser is exposed.
In other words, you might see behind www.coreasur.com?lecture=php&lec_num=5? Lecture = php & lec_num = 5 This is the GET method of data transfer.
So let's test it with the source.

file name is get.php in htdocs

<?php
    echo $_GET['happy'];
?>

play this file on browser.
url is localhost/get.php

atom

php image

result

php image

Nothing was displayed.

play this file one more.
url is localhost/get.php?happy=IamHappy

result

php image

this time, use 2 get data.

file name is get2.php in htdocs

<?php
    echo "{$_GET['who']} have(has) a {$_GET['machine']}";
?>

atom

php image

write down the address as below in browser.

http://localhost/get2.php?who=I&machine=MacBookPro

result

php image

Now let's look at the POST method. This time, let's practice with the registration form you have already created.

Create a join_result.php file in the join folder and enter the following code. POST is case sensitive, please capitalize it.

file name is join_result.php in join folder

<?php
  echo "let's learn post.<br />";

    echo "id ............. {$_POST['id']} <br />";
    echo "name ............. {$_POST['yourname']} <br />";
    echo "password ............. {$_POST['pwd']} <br />";
    echo "confirm password ............. {$_POST['pwd2']} <br />";
    echo "phone number.......... {$_POST['m1']} -{$_POST['m2']}-{$_POST['m3']} <br />";
    echo "sex ............. {$_POST['sex']} <br />";
    echo "address ............. {$_POST['addr']} <br />";
    echo "hobby / computer ............. {$_POST['com']} <br />";
    echo "hobby / sports ............. {$_POST['sports']} <br />";
    echo "hobby / shopping ............. {$_POST['shop']} <br />";
    echo "hobby / movie ............. {$_POST['mov']} <br />";
?>

Run the join-form.php file and enter a random value and press submit.


atom

php image

result

php image php image

!!!