2015-07-21 91 views
-2

我有這已經編碼的PHP郵件形式:我必須使用哪種語言才能獲得成功或PHP郵件表單的錯誤情況?

PHP Mail Form

而且我想我會使用CSS和jQuery編碼的旗幟,如果表單成功發送郵件,或者不:

Success

我想知道我可以使用什麼語言,使之發生什麼呢?你有什麼建議?

這裏是形式我的html代碼:

<form id="my_form" enctype="multipart/form-data" method=POST action=formmail.php> 
    <input type="hidden" name="subject" value="formmail"> 


<!-- PSEUDO --> 

<p> 

    <h3> 
     PSEUDO 
     <font class="color-red"> 
     * : 
     </font> 
     <span class="padding1"><input type="text" class="form-control" name="pseudo" aria-required="true" aria-invalid="false"></span></p><br> 


<!-- EMAIL --> 

    <p> 
     EMAIL 
     <font class="color-red"> 
      * : 
     </font> 
     <span class="your-email padding1"><input type="email" class="form-control" name="email" aria-required="true" aria-invalid="false"></span></p><br> 

    <!-- MOTO --> 

    <p> 
     QUOTE 
     <font class="color-red"> 
     * : 
     </font> 

    <span class="moto padding1"><input type="moto" class="form-control" name="moto" aria-invalid="false"></span> </p><br> 



    <!-- LINK OF THE GIF --> 

<p> 
    LINK OF THE GIF 
    <font class="color-red"> 
    * : 
    </font> 
    <span class="link-url padding1"><input type="link_url" class="form-control" name="link_url" aria-invalid="false"></span> </p><br> 


    <!-- RECAPTCHA --> 
    <div align="center"> 
    <p><div class="g-recaptcha" data-sitekey="6LehFQoTAAAAAMHlOs6vgktrCdFo485AoHwmp9Cp"></div></p><br><h3> 


    <!-- SUBMIT --> 

<p><input type="image" src="img/submitbutton.png" value="send"/><img class="ajax-loader" src="http://s584101063.onlinehome.fr/wp-content/plugins/contact-form-7/images/ajax-loader.gif" alt="Envoi en cours ..." style="visibility: hidden;"></p></div> 


</div> 
</form> 

這是我的PHP:

if($_SERVER["REQUEST_METHOD"] === "POST") 
    { 
     //form submitted 

     //check if other form details are correct 

     //verify captcha 
     $recaptcha_secret = "MY_SECRET_RECAPTCHA"; 
     $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$recaptcha_secret."&response=".$_POST['g-recaptcha-response']); 
     $response = json_decode($response, true); 
     if($response["success"] === true) 
     { 

      Header("Location: MY_WEBSITE"); 





      $TO = "MY_MAIL"; 

$subject = "Submission"; 

$h = "From: " . $_POST['email']; 
$pseudo = $_POST['pseudo']; 
$email = $_POST['email']; 
$link_url = $_POST['link_url']; 
$moto = $_POST['moto']; 

$HTTP_POST_VARS = $_POST; 


$message = "Pseudo : " . $pseudo . "\n\n " . "Email : " . $email . " \n\n" . "Text : " . $moto . "\n\n " . "URL du GIF : " . $link_url; 

mail($TO, $subject, $message, $h); 








     } 



     else 
     { 
      $result 
     } 
    } 


?> 
+0

你的腳本是敞開誰願意濫用你的代碼,以便垃圾郵件發送者發送電子郵件與viagra和加拿大藥房。您應該考慮清理用戶輸入。 – skrilled

+0

不知道你在問什麼 – 2015-07-21 22:13:11

+0

@skrilled the recaptcha will help – 2015-07-21 22:13:47

回答

2

非常基本的理念:

$test=mail($TO, $subject, $message, $h); 

if($test){ 
echo 'EmAIL WORK'; 
}else{ 
echo 'EmAIL Fail'; 

} 
0

編輯:袞的答覆工作非常好吧,但我的問題並不清楚,這裏是我發現做我想做的事情:

感謝袞,但它不是真的是我預料之中的事, 我發現如何做到這一點,它的工作原理:)

<?php 
if(isset($_GET['id']) AND $_GET['id']==2) { 

    echo '<script type="text/javascript">'; 

    echo ' 
    $("#success-bar").css("display", "inline"); 
    $("#success-bar").addClass("animated bounceInDown") 

    $("#success-bar").one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", 

    function(){ 

     $("#success-bar").removeClass("animated bounceInDown") 

     $("#close2").click(function() { 

     $("#success-bar").addClass("animated bounceInUp") 
     $("#success-bar").hide() 


     $("#success-bar").one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", 

    function(){ 

$("#success-bar").addClass("animated bounceInDown") 

     }); 

     }); 

     });'; 

echo '</script>'; 


} 

elseif(isset($_GET['id']) AND $_GET['id']==3) { 

    echo 'FALSE'; 

} 

?> 
+0

好的,但你假設郵件沒有檢查發送。因爲你正在使用POST,我沒有看到你檢查得到的變量在哪裏從 – 2015-07-22 00:10:09

+0

即將到達它通過PHP郵件中的標題位置進行檢查,其中重定向到ID :) – alexandresecanove

+0

根據驗證碼,如果它是好的或不是當然(如果目前確定郵件已發送) – alexandresecanove