Home > Backend Development > PHP Tutorial > php如何样判断多个post值是否为空

php如何样判断多个post值是否为空

WBOY
Release: 2016-06-13 12:41:02
Original
1462 people have browsed it

php怎么样判断多个post值是否为空

本帖最后由 gz109 于 2013-07-22 17:37:50 编辑 比如一个表单,很多个选项,怎么样来用php来判断值是否为空或者为正确数值

<form action="add.php" method="post"><br />
<input type="text" name="name"><br />
<input type="text" name="name2"><br />
<input type="text" name="name3"><br />
<input type="text" name="name4"><br />
<input type="text" name="name5"><br />
</form><br />
<br />
<?php<br />
$name1=$_POST[name1];<br />
$name2=$_POST[name2];<br />
$name3=$_POST[name3];<br />
$name4=$_POST[name4];<br />
$name5=$_POST[name5];<br />
<br />
//插入数据库,如果是就单独判断一个变量,可以用IF,那如果多个怎么办呢<br />
if($name1==''){<br />
   echo '请输入数据';<br />
   exit;<br />
}<br />
<br />
$sql="insert into book values('$name1','$name2','$name3','$name4','$name5')";<br />
mysql_query($sql);<br />
<br />
?>
Copy after login

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