2017-09-04 7 views
0

私は、そのコードで次のようにメールフォームを持っています。私のCKEditorバージョンの保存ボタンを押すか、電子メールが配信に失敗したとき、このエラーメッセージがのみ表示されますPHPやHTMLメールフォーム送信していませんが正常に

//Email FAILED response 

echo "<button class=\"btn btn-info\" onclick=\"myFunction()\">Return to AntiMalwareProgram</button>\n"; 
echo "\n"; 
echo "<script>\n"; 
echo "function myFunction() {\n"; 
echo "  window.history.back();\n"; 
echo "}\n"; 
echo "</script>\n"; 

    echo "<script>console.log('Thank you for choosing to submit a support ticket to antimalwareprogram! How ever there has been a error! Currently there is only one know cause to this issue, you must have pressed the save button on the email body message! Please use the send button and resubmit your ticket! We are very sorry!');</script>\n"; 
    echo "<script>alert('Error: press ok for more info!');</script>\n"; 


echo "\n"; 
echo " <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/twitter- bootstrap/2.3.2/css/bootstrap.css\">\n"; 

echo " <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css  \">\n"; 
echo " <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js\"></script>\n"; 
echo " <script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js\"> </script>\n"; 
    echo " <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.2/css/bootstrap.css\">\n"; 

echo "<style type=\"text/css\">\n"; 
echo " #message {\n"; 
echo " position: fixed;\n"; 
echo " top: 50px;\n"; 
echo " left: 0;\n"; 
echo " width: 100%;\n"; 
echo "}\n"; 
echo "#inner-message {\n"; 
echo " margin: 0 auto;\n"; 
echo "}\n"; 
echo " </style>\n"; 
echo "\n"; 
echo "<div id=\"message\">\n"; 
echo " <div style=\"padding: 5px;\">\n"; 
echo "  <div id=\"inner-message\" class=\"alert alert-danger\">\n"; 
echo "   <strong>Error in sending of message! Details:</strong> Thank you for choosing to submit a support ticket to antimalwareprogram! How ever there has been a error! Currently there is only one know cause to this issue, you must have pressed the save button on the email body message! Please use the send button and resubmit your ticket! We are very sorry!\n"; 

echo "  </div>\n"; 
echo " </div>\n"; 
echo "</div>\n"; 

:私は何をしようとしている

<link href="https://antimalwareprogram.co/oxygen%20/template/css/responsive.css" rel="stylesheet"> 
    <link id="css-preset" href="https://antimalwareprogram.co/oxygen%20/template/css/presets/preset1.css" rel="stylesheet"> 
    <link href="https://antimalwareprogram.co/oxygen%20/template/css/main.css" rel="stylesheet"> 
    <link href="https://antimalwareprogram.co/oxygen%20/template/css/bootstrap.min.css" rel="stylesheet"> 
    <link href="https://antimalwareprogram.co/oxygen%20/template/css/lightbox.css" rel="stylesheet"> 
    <link href="https://antimalwareprogram.co/oxygen%20/template/css/font-awesome.min.css" rel="stylesheet"> 
    <link href="https://antimalwareprogram.co/oxygen%20/template/css/animate.min.css" rel="stylesheet"> 

    <link href='https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700' rel='stylesheet' type='text/css'> 
<script type="text/javascript" src="https://antimalwareprogram.co/oxygen%20/template/js/jquery.js"> </script> 
    <script type="text/javascript" src="https://antimalwareprogram.co/oxygen%20/template/js/bootstrap.min.js"> </script> 

    <script type="text/javascript" src="https://antimalwareprogram.co/oxygen%20/template/js/jquery.inview.min.js"></script> 
    <script type="text/javascript" src="https://antimalwareprogram.co/oxygen%20/template/js/wow.min.js"> </script> 
    <script type="text/javascript" src="https://antimalwareprogram.co/oxygen%20/template/js/mousescroll.js"></script> 
    <script type="text/javascript" src="https://antimalwareprogram.co/oxygen%20/template/js/smoothscroll.js"> </script> 
    <script type="text/javascript" src="https://antimalwareprogram.co/oxygen%20/template/js/jquery.countTo.js"> </script> 
    <script type="text/javascript" src="https://antimalwareprogram.co/oxygen%20/template/js/lightbox.min.js"> </script> 
    <script type="text/javascript" src="https://antimalwareprogram.co/oxygen%20/template/js/main.js"></script> 
    <script src="https://cdn.ckeditor.com/4.7.2/full-all/ckeditor.js"> </script> 
     <script src="https://antimalwareprogram.co/ckeditor/config.js"></script> 
     <script src="https://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script> 

<!--Email CORRECT Response!--> 
    <script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){ 
$("#f3").validate({ 
    rules: { 
    cktext: { 
     required: true, 
     minlength: 10 
     } 
    }, 
    submitHandler: function() { 
console.log('successful submission! Email sent to us! Thank you for choosing to submit a ticket to antimalwareprogram we will get back to you asap!'); 
alert('successful submission! Email sent to us! Thank you for choosing to submit a ticket to antimalwareprogram we will get back to you asap!'); 
    } 
}); 

//deal with copying the ckeditor text into the actual textarea 
CKEDITOR.on('instanceReady', function() { 
    $.each(CKEDITOR.instances, function (instance) { 
    CKEDITOR.instances[instance].document.on("keyup", CK_jQ); 
    CKEDITOR.instances[instance].document.on("paste", CK_jQ); 
    CKEDITOR.instances[instance].document.on("keypress", CK_jQ); 
    CKEDITOR.instances[instance].document.on("blur", CK_jQ); 
    CKEDITOR.instances[instance].document.on("change", CK_jQ); 
    }); 
}); 

function CK_jQ() { 
    for (instance in CKEDITOR.instances) { 
     CKEDITOR.instances[instance].updateElement(); 
    } 
} 
});//]]> 

</script> 

<?php 
//if "email" variable is filled out, send email 
    if (isset($_REQUEST['email'])) { 

    //Email information 
    $admin_email = "[email protected]"; 
    $email = $_REQUEST['email']; 
    $subject = $_REQUEST['subject']; 
    $Message = $_REQUEST['cktext']; 
$ItemAddress = $_REQUEST['ItemAddress']; 
     $ItemAddress2 = $_REQUEST['ItemAddress2']; 
    $ItemCity = $_REQUEST['ItemCity']; 
    $ItemState = $_REQUEST['ItemState']; 
    $ItemZip = $_REQUEST['ItemZip']; 
    $Size = $_REQUEST['Size']; 
    $Location = $_REQUEST['Location']; 



    $body = " Name: $name\n E-Mail: $email\n Email Body: $Message\n Location Entered: $Location\n Address: $ItemAddress\n Address Line 2: $ItemAddress2\n City: $ItemCity\n State: $ItemState\n Zip Code: $ItemZip"; 
    //send 
    mail($admin_email, "$subject", $body, "From:" . $email); 

    //Email FAILED response 

echo "<button class=\"btn btn-info\" onclick=\"myFunction()\">Return to AntiMalwareProgram</button>\n"; 
echo "\n"; 
echo "<script>\n"; 
echo "function myFunction() {\n"; 
echo "  window.history.back();\n"; 
echo "}\n"; 
echo "</script>\n"; 

    echo "<script>console.log('Thank you for choosing to submit a  support ticket to antimalwareprogram! How ever there has been a error! Currently there is only one know cause to this issue, you must have pressed the save button on the email body message! Please use the send button and resubmit your ticket! We are very sorry!');</script>\n"; 
    echo "<script>alert('Error: press ok for more info!');</script>\n"; 


echo "\n"; 
echo " <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/twitter- bootstrap/2.3.2/css/bootstrap.css\">\n"; 

echo " <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css \">\n"; 
echo " <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js\"></script>\n"; 
echo " <script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js\"></script>\n"; 
    echo " <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.2/css/bootstrap.css\">\n"; 

echo "<style type=\"text/css\">\n"; 
echo " #message {\n"; 
echo " position: fixed;\n"; 
echo " top: 50px;\n"; 
echo " left: 0;\n"; 
echo " width: 100%;\n"; 
echo "}\n"; 
echo "#inner-message {\n"; 
echo " margin: 0 auto;\n"; 
echo "}\n"; 
echo " </style>\n"; 
echo "\n"; 
echo "<div id=\"message\">\n"; 
echo " <div style=\"padding: 5px;\">\n"; 
echo "  <div id=\"inner-message\" class=\"alert alert-danger\">\n"; 
echo "   <strong>Error in sending of message! Details:</strong> Thank you for choosing to submit a support ticket to antimalwareprogram! How ever there has been a error! Currently there is only one know cause to this issue, you must have pressed the save button on the email body message! Please use the send button and resubmit your ticket! We are very sorry!\n"; 

echo "  </div>\n"; 
echo " </div>\n"; 
echo "</div>\n"; 


    } 

//if "email" variable is not filled out, display the form 
    else { 
?> 

<form method="post" name="f3" id="f3"> 
     <input name="subject" type="text" class="form-control" placeholder="Email Subject" autocomplete="off" required="required"/> 
    <input name="name" type="text" class="form-control" placeholder="Name" required="required"/> 
    <input type="email" name="email" class="form-control" placeholder="Email Address" required="required"> 





<!DOCTYPE html> 
<html> 
    <body> 
     <label for="cktext">Email Body!</label> 

<textarea class="ckeditor" name="cktext" id="cktext" placeholder="Email Body!"></textarea>    


     </body> 
</html> 

        <button type="submit" class="btn-submit">Send! </button>     

    </form> 

<?php 
    } 
?> 

はエラーメッセージを表示しています!

submitHandler: function() { 
console.log('successful submission! Email sent to us! Thank you for choosing to submit a ticket to antimalwareprogram we will get back to you asap!'); 
alert('successful submission! Email sent to us! Thank you for choosing to submit a ticket to antimalwareprogram we will get back to you asap!'); 
    } 
}); 

メール配信の成功に表示され、唯一の送信ボタンの上に他のプレスが失敗した応答を送信する必要があります と私は、この成功のメッセージを表示したいです。

これは機能しません。私はalert('successful submission! Email sent to us! Thank you for choosing to submit a ticket to antimalwareprogram we will get back to you asap!');を得るが、それはメッセージの送信を意味しない。実際にはそれは意味しませんでした。私の電子メールは、ckeditorの保存ボタンが押された場合にのみ送信されます。これは、私が望むものの反対です。これを修正する方法はありますか?

答えて

0

私はこのためにJavaScriptを使用しないことをお勧めします。代わりにPHPMailerのようなものを使用してください。

Here's a tutorial for it

あなたがphpmailerのを使用している場合は、あなたのコードは次のようになります:

$mail = new PHPMailer(); 
$mail->setFrom("[email protected]", 'my name'); 
$mail->addAddress('[email protected]', 'your name'); 
$mail->Subject = $subject; 
$mail->Body = $message; 
$mail->isHTML(true); 
$mail->send(); 

は、あなたの$messageもhtmlタグが含まれていることを確認します。プレーンテキストを送信するだけの場合は、isHTMLをfalseに設定します。

関連する問題