国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

PHP development basic tutorial forms and user input

1. Overview:

The $_GET and $_POST variables in PHP are used to retrieve information in the form, such as user input.

2. PHP form processing

One very important thing to note is that when processing HTML forms, PHP can process the data from the HTML page. The form elements in are automatically made available for use by PHP scripts.

Example: The code is as follows

The following example contains an HTML form with two input boxes and a submit button.

<html>
<head>
<meta charset="utf-8">
<title>php中文網(wǎng)(php.cn)</title>
</head>
<body>
<!-- 新建一個(gè)帶有兩個(gè)輸入框和一個(gè)提交按鈕的表單 -->
<!-- action為提交的的那個(gè)頁(yè)面,method為提交方式,有$POST和$GET兩種 -->
<form action="" method="post">
名字: <input type="text" name="name">
<br/>
年齡: <input type="text" name="age">
<br/>
<input type="submit" value="提交">
<hr>
 大家好,我是 <?php echo $_POST["name"]; ?>!<br>
今年 <?php echo $_POST["age"]; ?>  歲。 
</form>
</body>
</html>

The output is as shown on the right

More details, we will explain in the next section

3. Form Validation

Under no circumstances should user-submitted data be considered in good faith, so user input should be verified whenever possible (via the client script). Browser validation is faster and reduces the load on the server.

If user input needs to be inserted into the database, you should consider using server validation. A good way to validate a form on the server is to pass the form to itself, rather than jumping to a different page. This way users can get error messages on the same form page. It will be easier for users to find errors.

Learning experience:

  • # There are two basic forms submission methods: $GET and $POST, both of which implement the same function. , but the implementation process is different. We will discuss it in detail in the next few sections.

  • Form verification is required at any time.

  • Remember to enable apache


Continuing Learning
||
<html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <!-- 新建一個(gè)帶有兩個(gè)輸入框和一個(gè)提交按鈕的表單 --> <!-- action為提交的的那個(gè)頁(yè)面,method為提交方式,有$POST和$GET兩種 --> <form action="" method="post"> 名字: <input type="text" name="name"> <br/> 年齡: <input type="text" name="age"> <br/> <input type="submit" value="提交"> <hr> 大家好,我是 <?php echo $_POST["name"]; ?>!<br> 今年 <?php echo $_POST["age"]; ?> 歲。 </form> </body> </html>
submitReset Code