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
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
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31