When PHP accepts information submitted through an HTML form, it saves the submitted data in a global array, and we can get the values by calling the system-specific array of automatic global variables. The common automatic global variables are as follows:
$_get
$_post
$_request
The most commonly used automatic global variables in obtaining form data are $_get and $_post, which obtain data submitted by the Get method and the data submitted through the POST method, respectively. For example, a text box form control called "Txtage", if submitted using the Get method, can be used with the
$_get["Txtage"] or $_get[' txtage ']
Gets the value that it commits.
The $_request automatic global variable contains all the data for GET, POST, cookie, and file, and if you don't care about the data source, you can use the
$_request["Txtage"] or $_request[' txtage ' to get the submitted data.
Here is a simple example of getting the submitted data:
-->"); Echo ("Your name is:". $_post[' yourname ']); Output name Echo ("
"); Echo ("Your password is:". $_post[' passwd ']); Output Password echo ("
"); Echo ("Your query password question is:". $_post[' question ']); Query password question echo ("
"); Echo ("The answer to your query password is:". $_post[' Question2 ']); Query password answer echo ("
"); Echo ("Your date of birth is:". $_post[' Byear '). " Years. " $_post[' Bmonth ']. "Month". $_post[' Bday ']. "Day"); Date of birth echo ("
"); Echo ("Your gender is:". $_post[' gender ']); Gender Echo ("
"); Echo ("Your hobby is:
" ); Love foreach ($_post[' hobby '] as $hobby) {echo ($hobby. "
");
}
? > The corresponding form code is as follows:
<title>User Survey Form</title>
Welcome to this website, please enter the following personal data first:
Account:
Name:
Password:
Confirm Password:
Query password problem:
--Please choose--What's my pet name?Who is my best friend?What's my favorite color?My favorite movie?My favorite movie star?My favorite song?What's my favorite food?What's my biggest hobby?
Query password Answer:
Date of birth:
". $i." Years "; }?>
". $i." Month "; }?>
". $i." Day "; }?>
Gender:
Man
Woman
Please choose your hobby:
Dance
Tourism
Sing
Play