-2
我試圖在PHP中聯繫我們表單,現在當它提交併且用戶數據沒有填寫在表單中時,應該引用用戶返回來填充它。所以我的代碼目前已經是:PHP中的HTML聯繫我們表格
<?php
$all = 'All fields are required, please fill <a href="\">the form</a> again.'
$action=$_REQUEST['action'];
if ($action=="") /* display the contact form */
{
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
Your name:<br>
<input name="name" type="text" value="" size="30"/><br>
Your email:<br>
<input name="email" type="text" value="" size="30"/><br>
Your message:<br>
<textarea name="message" rows="7" cols="30"></textarea><br>
<input type="submit" value="Send email"/>
</form>
<?php
}
else /* send the submitted data */
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
if (($name=="")||($email=="")||($message==""))
{
echo $all;
}
else{
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Message sent using your contact form";
// mail("[email protected]", $subject, $message, $from);
echo "Email sent!";
}
}
?>
現在,由於某種原因,這裏我使用 All fields are required, please fill <a href="\">the form</a> again.
它並不隱藏其自身 它顯示了,我覺得很奇怪?
Here is the live link to further explain
爲什麼不在關閉每個輸入標籤之前放置'required'? – Anonymous