How does php determine whether multiple post values are null?-php Tutorial

Source: Internet
Author: User
How does php determine whether multiple post values are empty? this post is finally edited by gz109 from 2013-07-, for example, a form, multiple options, how can I use php to determine whether the value is null or the correct value? & lt; form & nbsp; actionadd. php & nbsp; methodpost & gt; & lt; input & nbsp; how does typ php determine whether multiple post values are empty?

This post was last edited by gz109 at 17:37:50

For example, how can I use php to determine whether a value is null or a correct value for a form with many options?



$ Name1 = $ _ POST [name1];
$ Name2 = $ _ POST [name2];
$ Name3 = $ _ POST [name3];
$ Name4 = $ _ POST [name4];
$ Name5 = $ _ POST [name5];

// Insert the database. IF it is a single variable, you can use IF. what IF there are multiple variables?
If ($ name1 = ''){
Echo 'Enter the data ';
Exit;
}

$ SQL = "insert into book values ('$ name1', '$ name2', '$ name3', '$ name4', '$ name5 ')";
Mysql_query ($ SQL );

?>

Share:


------ Solution --------------------
// Set
$ _ POST = array ('name' => '', 'name2' => 'e', 'name3' => 'R', 'name4' => '', 'name5' => '');

$ T = array_keys ($ _ POST, ''); // if the space is not empty, use this
$ T = array_keys (array_map ('trim', $ _ POST), ''); // Use this parameter if the space is null.
If ($ t) {// empty data item
Print_r ($ t); // The value is an empty item.
}

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.