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.

   php中文网(php.cn) 
名字:
年龄:

大家好,我是 !
今年 岁。

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
||
php中文网(php.cn)
名字:
年龄:

大家好,我是 !
今年 岁。
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!