以下は問い合わせフォームのための私のhtmlコードされて使用してはGoogle App Engine上でPHPを経由してHTMLの接触 - 私達のフォームを使用して電子メールを送信しようとすると、AngularJsを
<div class="col">
<h3>Say hello</h3>
<div ng-show="error" class="error">
<p>Something wrong happened!, please try again.</p>
</div>
<form method="post" role="form" ng-submit="sendMessage(input)" class="contactForm" name="form" id="contact_form" >
<input type="text" name="firstname" id="firstname" placeholder="Name" required="required" ng-model="input.name">
<input type="text" name="telephone" id="telephone" placeholder="Telephone" required="required" ng-model="input.telephone">
<input type="text" name="email" id="email" placeholder="Email" required="required" ng-model="input.email">
<textarea name="comments" maxlength="1000" cols="20" rows="3" placeholder="Comment" required="required" ng-model="input.message"></textarea>
<button type="submit" name="submit" value="submit" ng-disabled="!form.$valid">Submit</button>
</form>
<!-- <div ng-show="process" style="text-align:center">
<img class="loader" src="" />
Sending ...
</div> -->
<div ng-show="success" class="success">
<p>Thank you for taking the time to contact us</p>
<p>Have A Great Day!</p>
</div>
<div class="clearboth"></div>
</div>
app.jsから私のコード
var app = angular.module('example', []).
run(['$rootScope', '$http', '$browser', '$timeout', "$route", function ($scope, $http, $browser, $timeout, $route) {
$scope.sendMessage = function(input) {
input.submit = true;
$scope.success = false;
$scope.error = false;
$scope.loaded = true;
$scope.process = true;
$http({
method: 'POST',
url: 'js/sendemail.php',
data: input,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
})
.success(function(data) {
if (data.success) {
$scope.success = true;
$scope.process = false;
$("form").trigger("reset");
} else {
alert("error :" +data);
$scope.error = true;
}
});
};
以下は
私はJavaSでログを保持している私のsendemail.phpコード
<?php
$response = array('success' => false);
$formData = file_get_contents('php://input');
$data = json_decode($formData);
if ($data->submit) {
$name = $data->name;
$email = $data->email;
$telephone = $data->telephone;
$message = $data->message;
if ($name != '' && $email != '' && $message != '' && $telephone != '') {
$mailTo = '[email protected]';
$subject = 'New Contact Form Submission';
$body = 'From: ' . $name . "\n";
$body .= 'Email: ' . $email . "\n";
$body .= 'Telephone: ' . $telephone . "\n";
$body .= "Message:\n" . $message . "\n\n";
$success = mail($mailTo, $subject, $body);
if ($success) {
$response[ 'success' ] = true;
} else {
$response[ 'success' ] = false;
}
}
}
echo json_encode($response);
?>
ですデータがhtmlかどうかをチェックするcript sendMessage関数。はい、来る。私は警告メッセージでデータを見ることができます。
Google App Engine - >設定 - >メールアドレスも多くのリンクを更新して更新しました。
フォームに送信ボタンをクリックしたとき。 JSアラート(「エラー」+データ)で書いた警告メッセージが表示されます。 アラートボックスは、PHPコード全体で構成されています。以下
私のapp.yamlファイルには、誰かがこの問題を解決するには、私を助けてください、あまりにも
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url:/
static_files: static/index.html
upload: static/
- url: /images
static_dir: static/images
- url: /css
static_dir: static/css
- url: /js
static_dir: static/js
- url: /pages
static_dir: static/pages
- url: /static
static_dir: static
- url: /(.+\.php)
script: \1
- url: /.*
script: start.application
です。
Windowsアプリケーションでxampを使って同じアプリケーションを実行したとき。そのPHPの問題を与えることは少なくともありません。電子メールは送信されません。 –
INFO 2016-04-26 00:52:48,094 module.py:787]デフォルト: "POST /js/sendemail.php HTTP/1.1" 200 961 これも見ることができます。 Googleアプリエンジンのログに記録します。 –