<form action="http:\\127.0.0.1\rechecking.php" method="post" enctype="multipart/form- data"><pre>
Enter your first Name: <input type="text" name="fname" size="15"></input>
Enter your Last Name: <input type="text" name="lname" size="15"></input>
Your Email Id: <input type="text" name="email" size="15"></input>
Your age: <input type="text" name="age" size="1"></input>
Upload your Image: <input type="file" name="file"></input>
<input type="Submit" value="Submit"></input></pre>
</form>
<?php
if(!empty($_POST["fname"])&&!empty($_POST["lname"])&&!empty($_POST["email"])&&!empty($_POST["age"]))
{
if($_FILES["file"]["error"]>0)
{
echo $_FILES['file']['error'] ."error is there in uploading files";
}
}
else
{ $emt=array($_POST['fname']=>"Firstname",$_POST['lname']=>"LastName",$_POST['email']=>"Email",$_POST['age']=>"Age");
foreach($emt as $value=>$variable)
{
if(empty($value))
{
echo $variable." cannot be left blank<br />";
}
}
}
?>
問題是,在所有的空格留在我的formIts只顯示關聯數組的最後ement。 對於例如: - 名字,姓氏,電子郵件,年齡然後它會顯示'年齡提交不能留空' 類似地,如果年齡已填寫在我的輸入字段,那麼它只會顯示'電子郵件字段不能留空「 嗯,我希望它顯示是空的所有字段的名稱卡住空和foreach
'http:\\ ...'應該有正斜槓:'http:// ...' – Blender 2013-04-09 19:35:28
請參閱下面的答案。 Alsn交換變量和值在邊foreach。我的意思是'foreach($ emt as $ variable => $ value)' – 2013-04-09 19:45:04