The "welcome.php" file looks like this:
The script above will output the following result:
Welcome John.
You are are years old.
The PHP $_get and $_post variables will be explained in detail below.
form validation [form Validation]
The information entered by the user should be validated as much as possible through client-side scripting (e.g. JavaScript) browsers, and the validation of information through the browser can improve efficiency and reduce download pressure on the server.
If the user enters information that needs to be stored in the database, then you must consider validation on the server side. The best way to verify the validity of information on a server is to send the form information to the current page for validation, not to other pages. With this method, if there is an error in the form, the user can get the error message directly on the current page. This makes it easier to find error messages that exist.
The PHP $_get variable is getting "value" from the form by a GET method.
$_get variable
The $_get variable is an array that contains the name [name] and values [value] (these names and values are sent through the HTTP GET method and can be exploited).
The $_get variable uses "Method=get" to get the form information. The information sent through the Get method is visible (it will appear in the browser's address bar), and it has a length limit (the total length of the information cannot exceed 100 characters [character]).
Case
<form action= "welcome.php" method= "get" >
Name: <input type= "text" name= ' name '/> Age
: <input Type= "Text" name= "age"/>
<input type= "Submit"/>
</form>
The URL is displayed when the user clicks the Submit button
The "welcome.php" file can use the "$_get" variable to get the form data (note: The name in the Form column [form field] will automatically be used as the ID keyword in the "$_get" array):
Welcome <?php echo $_get["name"] >.<br/>you are echo <?php "age"; $_get[?> years
Why use "$_get"?
Important: When you use the "$_get" variable, all variable names and variable values are displayed in the URL address bar, so when you send a message that contains a password or some other sensitive information, you can no longer use this method. Because all the information is displayed in the URL address bar, we can put it in the Favorites folder as a label. This is very useful in many cases.
Note: If you need to send a variable value that is too large, the HTTP get method does not apply. The amount of information sent cannot exceed 100 characters.
$_request variable
The PHP $_request variable contains the contents of $_get, $_post, and $_cookie.
The PHP $_request variable can be used to get form data sent by both the "get" and "POST" methods.
Case
Welcome <?php echo $_request["name"] >.<br/>you are echo <?php "age"; $_request[?> years
The function of the PHP $_post variable is to get the form variable sent by method = "POST".
$_post variable
The $_post variable is an array of [name] value [value] (these names and values are sent through the HTTP POST method and can be exploited)
The $_post variable uses "Method=post" to get the form information. The information sent through the Post method is not visible, and it does not have a limit on the length of the information.
Case
<form action= "welcome.php" method= "POST" >
Enter your name: <input type= "text" name= "name"/>
Enter Your age: <input type= ' text ' name= ' age '/> <input
' type= ' Submit '/>
</form>
The URL does not contain any form data when the user clicks the Submit button
The "welcome.php" file can use the "$_post" variable to get the form data (note: The name in the Form column [form field] will automatically be used as the ID keyword in the "$_post" array):
Welcome <?php echo $_post["name"];? >.<br/> You are <?php
echo $_post[' age ';?> years old!
Why do you use $_post?
Variables sent over HTTP POST are not displayed in the URL
The size of the variable is not limited
However, because variables cannot be displayed in a URL, it is not possible to store the page as a label in a Favorites folder.
$_request variable
The PHP $_request variable contains the contents of $_get, $_post, and $_cookie
The PHP $_request variable can be used to get form data sent by both the "get" and "POST" methods.
Case
Welcome <?php echo $_request["name"];? >.<br/> You are <?php
echo $_request[' age ';?> years old!
The above submission form after PHP to obtain the content of the implementation method is small series to share all the content, hope to give you a reference, but also hope that we support the cloud-dwelling community.