[head First Php&mysql] reading notes-feedback from the customer (fourth chapter)

Source: Internet
Author: User

Sometimes a blank form is sent to the customer, because nothing is filled out directly. Oh, how bad.

Introduces 2 functions, Isset and empty. Isset returns True for the assigned variable, regardless of the value assigned, the empty string is also true;empty when the parameter inside is null is the return true;

The null value has null, ' ', 0,false.

This will not be able to respond when the user submits the empty item. Should be in the client with JS first to deal with, and then PHP processing, PHP as the last wall inspection.

If there is a problem with submitting something, use an if loop like this to judge it.

After judging, in case of error, but also to echo back a form to the customer refill.

Just use the HTML code.

<?php

if (Out_false) {

?>

<form action= "<?php echo $_server[php_self]?>" method= "POST" >
<input type= "text" name= "user" value= "<?php echo $user?>" >
<input type= "pasword" name= "password" value=<?php echo $password?>>
<input type= "Submit" value= "Submit"/>
</form>

<?php
}
?>

<?php?> is outside the HTML code, but the form part is still inside the if logic, and this thing $_server[php_self], you can refer to the URL of the form submitted by the foreground. If the form data is incorrectly filled in, return a form directly, and the returned form records what was previously filled. <?php Echo $password?> directly into the form with PHP code, but this time the form address URL is. PHP ends, be careful.
In addition, you can use Isset ($_post[' submit ') to determine whether the form is submitted, click Submit, there is a value to the Super global variable, isset is true.


In addition, we must make each row of the table unique in the database. This is what the primary key is. This is going to change the data table, can not directly drop table dropped ...
ALTER TABLE name add ID int NOT NULL auto_increment First,add primary KEY (ID)
The main idea is to add the Id,int type, cannot be empty, each time you add 1, put in the first column, add the primary key, (each table has only one primary key drop), so that each row of data is unique.

What do you do with the only primary key? Read it tomorrow and write again. Hey, want to combine exertion.




[head First Php&mysql] reading notes-feedback from the customer (fourth chapter)

Related Article

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.