2017-06-30 4 views
-2

私はPHPで連絡先フォームを作成しようとしましたが、フォームが記入されていないユーザーデータは、再度入力する必要があります。私は現在持っているコードは次のとおりです。私はそれが私は非常に奇妙見つけるどの現れる自己 を隠していないこと All fields are required, please fill <a href="\">the form</a> again.を使用しているいくつかの理由で今HTML in PHPお問い合わせフォーム

<?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!"; 
     } 
    } 
?> 

Here is the live link to further explain

+0

各入力タグを閉じる前に 'required'を入れてみませんか? – Anonymous

答えて

0

私は 2番目の文字列がでfiishedしなければならない、あなたはコードの間違いを持っ​​ていると仮定「;」

関連する問題