質問編集履歴
1
外部サービスへのリンクを削除しコードを添付
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,4 +30,110 @@
|
|
30
30
|
|
31
31
|
コードは下記となります。
|
32
32
|
|
33
|
+
```PHP
|
34
|
+
|
35
|
+
define("EMAIL_TO_YOU_SUCCESS", "Your message has been sent successfully!");
|
36
|
+
|
37
|
+
define("EMAIL_TO_QUESTIONER_SUCCESS", "Your message has been sent to you successfully!");
|
38
|
+
|
39
|
+
if (mb_send_mail(YOUR_EMAIL, QUESTIONER_SUBJECT, $to_you_massage, $to_you_header)) {
|
40
|
+
|
41
|
+
// if the message is sent
|
42
|
+
|
43
|
+
print EMAIL_TO_YOU_SUCCESS;
|
44
|
+
|
45
|
+
} else {
|
46
|
+
|
47
|
+
// if the message is failed to send
|
48
|
+
|
49
|
+
print EMAIL_TO_YOU_FAILED;
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
```
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
```jQuery
|
58
|
+
|
59
|
+
$.ajax({
|
60
|
+
|
61
|
+
url: $form.attr('action'),
|
62
|
+
|
63
|
+
type: $form.attr('method'),
|
64
|
+
|
65
|
+
data: $form.serialize(),
|
66
|
+
|
67
|
+
timeout: 10000,
|
68
|
+
|
69
|
+
beforeSend: function(xhr, settings) {
|
70
|
+
|
33
|
-
|
71
|
+
// disable the submit button prevending from double sending
|
72
|
+
|
73
|
+
$submitButton.attr('disabled', true);
|
74
|
+
|
75
|
+
},
|
76
|
+
|
77
|
+
complete: function(xhr, textStatus) {
|
78
|
+
|
79
|
+
// re-activate the submit button
|
80
|
+
|
81
|
+
$submitButton.attr('disabled', false);
|
82
|
+
|
83
|
+
},
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
// after success to send
|
88
|
+
|
89
|
+
success: function(result, textStatus, xhr) {
|
90
|
+
|
91
|
+
// initialize values
|
92
|
+
|
93
|
+
$form[0].reset();
|
94
|
+
|
95
|
+
alert('OK');
|
96
|
+
|
97
|
+
console.log(result);
|
98
|
+
|
99
|
+
},
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
// if any sending errors
|
104
|
+
|
105
|
+
error: function(xhr, textStatus, error) {
|
106
|
+
|
107
|
+
alert('NG...');
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
});
|
112
|
+
|
113
|
+
```
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
```html
|
118
|
+
|
119
|
+
<form method="post" action="./mail/sendmail.php">
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
<div class="form-group">
|
124
|
+
|
125
|
+
<label for="fullname">Full Name</label>
|
126
|
+
|
127
|
+
<input id="fullname" class="form-control" type="text" name="fullname" value="">
|
128
|
+
|
129
|
+
</div>
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
<button type="submit" class="btn btn-primary">Submit</button>
|
136
|
+
|
137
|
+
</form>
|
138
|
+
|
139
|
+
```
|