我必须使用哪种语言来获取PHP邮件表单的成功或错误情况?

问题描述:

I've got a PHP mail form which is already coded :

PHP Mail Form

And I would like to appear a banner i coded using CSS and jQuery, if the form succeed to send a mail, or not :

Success

I would like to know what language could I use to make it happens ? What are your advices ?

Here is my html code for the form :

<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>

Here is my 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 . "

 " . "Email : " . $email . " 

" . "Text : " . $moto . "

 " . "URL du GIF : " . $link_url;

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








        }



        else
        {
            $result
        }
    }


?>

VERY basic idea:

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

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

}

EDIT : The Dagon's answer works very well, but my question was not clear, here is what I found to do what I wanted :

Thanks Dagon, but it was not really what I expected to do, I found how to do it, it works :)

<?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';

}

?>