In actual programming, the HTML code of the form and the PHP program that gets the form can be written to two files, or in the same PHP file. Beginner Web Interactive programming, for the sake of simplicity, you can use the latter, because this can reduce the number of Web pages within the site.
1. Let's look at a simple example
The password is: ". $pwd;}? >
This is the HTML code of the form and the PHP program that gets the form into the same PHP file.
This is after entering the user name ' Bin_goo ' and password for ' 123 ' after clicking on the effect of login.
2. Methods of improvement
Since the user name and password are entered, the form data and the information obtained by the server are displayed on the same page. What if you want to implement the form data disappears after clicking Login, only to show get information?
Here's how:
The password is: ". $pwd;} Elseecho ';? >
This implementation ensures that the form is no longer displayed when the output gets information. This is because the code in the else is executed when the login is not clicked, and the code in if is executed when the login is clicked, thereby hiding the form data.
The specific output is as follows:
This is after entering the user name ' Bin_goo ' and password for ' 123 ' after clicking on the effect of login.
The above describes the form code and PHP code to write to the same file, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.