PHP4 Practical Application Experience (2) _php tutorial

Source: Internet
Author: User
Author: Sun Sports

Now you uncover the other half of the puzzle-the "login.php" script file. If nothing happens, the script will accept the input name, check if the user exists, decide whether to allow or deny access to the site. Since you have not learned the conditional statements and logic processing of PHP, we are not going to give you a clear argument now-instead, we will show you how the data submitted in the previous table dropdowns is transferred to "login.php" and can be used by this file.


This is "login.php."

--------------------------------------------------------------------------------
< html>
< head>
< Basefont face= "song Body" >


< body>
< center>
< font face= "Arial" size= "-1" >
I wonder if you've ever heard of Shakespeare, <? Echo $name;
< p>
He demanded a bouquet of roses with another name, because the bundle might smell more fragrant.
< p>
What do you think?
</FONT>
</center>
</body>


--------------------------------------------------------------------------------
When you enter data into the form, for example ("Zhang San"), and submit, you will see the following page:

--------------------------------------------------------------------------------
I want to know if you've ever heard of Shakespeare, Zhang San.

He asked for a bouquet of roses with another name, and it would be more aromatic for that bundle to smell.

What do you think?
--------------------------------------------------------------------------------
You will see that whenever a form is submitted to a PHP script, the values of the variables in all the forms and the names of the forms are sent to the script in pairs, so that they can be called arbitrarily by the script. In the example above, when the form is submitted, the variable $name is automatically created in the script "login.php", and the value entered by the user in the form is assigned to the variable.

If you use Perl to do the same thing, you need to write the Perl code very clearly to get the values of the variables in the form. by automatically creating and assigning values, PHP simplifies your code and greatly improves the speed of development-form processing is one of two reasons PHP is better than Perl.

Obviously, PHP also supports the Post method of form submission, all you need to do is to label the value of method as "POST".



Of course, the example you just saw is very basic. To really order a heavyweight program, you need to know how to organize conditional statements. A very basic conditional statement is a comparison statement-for example: "If one and the other are equal, the action is done in some way"

PHP has a series of specially designed operators to facilitate use in conditional statements. Here is a list:

Assume $delta = 12 and $omega = 9



Operator
Significance
Express Way
Results

==
Equals
$delta = = $omega
False

!=
Not equal to
$delta! = $omega
True

>
Greater than
$delta > $omega
True

<
Less than
$delta < $omega
False

>=
Greater than or equal to
$delta > = $omega
True

<=
Less than or equal to
$delta <= $omega
False


PHP4 also added a new operator, "= = =", to test whether the two data values and types are the same, and there is a simple example in the last section of this section.


http://www.bkjia.com/PHPjc/316412.html www.bkjia.com true http://www.bkjia.com/PHPjc/316412.html techarticle Author: Sun Sport now gives you the other half of the mystery-login.php script file. If not unexpectedly, this script will accept the input name, check whether the user exists, decide to allow ...

  • 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.