The form code and PHP code are written in the same file

Source: Internet
Author: User
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.