PHP4 Practical Application Experience (2)_PHP Tutorial

WBOY
Release: 2016-07-21 16:03:02
Original
858 people have browsed it

Author: Sun Movement

Now I will reveal the other half of the mystery to you - the "login.php" script file. If nothing else, this script will accept the entered name, check to see if the user exists, and decide whether to allow or deny access to the site. Since you haven't learned PHP's conditional statements and logic processing yet, we are not going to explain it to you now - instead, we will just show you how the data submitted in the previous form is sent to "login.php" and can used by this file.


This is "login.php"

----------------------------- -------------------------------------------------- --
< html>
< head>
< basefont face="宋体">
< /head>

< body>
< center>
< font face="宋体" size="-1">
I want to know if you have heard of Shakespeare, < ? echo $name; ?>.
< p>
He asked for a bouquet of roses with another name because that bouquet might smell more fragrant.
< p>
What do you think?
< /font>
< /center>
< /body>

< /html>
------------ -------------------------------------------------- ------------------
When you enter data in the form, for example ("Zhang San"), and submit, you will see the following page:

------------------------------------------------- ----------------------------------
I wonder if you have heard of Shakespeare, Zhang San

He asked for a bouquet of roses with another name, just because that bouquet might smell more fragrant

What do you think?
-------------------------------------------------- ----------------------------------
You will see that whenever the form is submitted to PHP When scripting, all variable values ​​in the form and the name of the form will be sent to the script in pairs, so that they can be called arbitrarily by the script. In the above example, 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 also assigned to this variable.

If you were to do the same thing in Perl, you would need to write the Perl code very clearly to get the variable value in the form. By automatically creating and assigning values, PHP simplifies your code and greatly improves development speed - form handling is one of the two reasons why PHP is better than Perl.

Obviously, PHP also supports the POST method of form submission. All you need to do is to mark the value of METHOD as "POST".



Of course, the example you just saw is very basic. For really heavyweight programming, you need to know how to organize conditional statements. A very basic conditional statement is a comparison statement - for example: "If such and such are equal, then do this in a certain way"

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

Assume $delta = 12 and $omega = 9



Operator
Meaning
Expression
Result

==
Equal
$delta == $omega
False

!=
Not equal
$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 adds a new operator "===", which is used to test whether the two data values ​​and types are the same. At the end of this part There is a simple example in this section.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/316412.htmlTechArticleAuthor: Sun Movement will now reveal the other half of the mystery to you - the login.php script file. If nothing else, this script will accept the entered name, check if the user exists, and decide whether to allow...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template