2017-06-30 44 views
-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

+0

为什么不在关闭每个输入标签之前放置'required'? – Anonymous

回答

0

我假设你已经在代码中, 第二个字符串应该与fiished错误“;”