質問編集履歴

3

Send_Mail($result);を追加しました。

2019/05/18 09:20

投稿

amaturePy
amaturePy

スコア131

test CHANGED
File without changes
test CHANGED
@@ -164,7 +164,7 @@
164
164
 
165
165
 
166
166
 
167
-
167
+ Send_Mail($result);
168
168
 
169
169
  ?>
170
170
 

2

functionに実行コマンドを入れました。

2019/05/18 09:20

投稿

amaturePy
amaturePy

スコア131

test CHANGED
File without changes
test CHANGED
@@ -64,7 +64,7 @@
64
64
 
65
65
  && isset($_POST['password'])){
66
66
 
67
- $_SESSION["USER"] = 'USER';
67
+ $_SESSION["USER"] = 'USER';
68
68
 
69
69
  header("Location:error.php");
70
70
 
@@ -74,6 +74,16 @@
74
74
 
75
75
  }
76
76
 
77
+ if(isset($_POST['email'])){
78
+
79
+ echo "Plese check confirmation Email";
80
+
81
+ } else {
82
+
83
+ echo "We failded sending Email to you , please check your Email address again";
84
+
85
+ };
86
+
77
87
 
78
88
 
79
89
  $dsn ='mysql:host=localhost;dbname=microblog';
@@ -118,70 +128,76 @@
118
128
 
119
129
  }
120
130
 
121
- };
131
+ }
122
-
132
+
133
+
134
+
123
- function Send_Mail($to, $from, $title, $body){
135
+ function Send_Mail($to, $from, $title, $body, $header) {
124
-
125
-
126
136
 
127
137
  // メール送信
128
138
 
129
- //mb_language('ja');
139
+ mb_language('e');
130
140
 
131
141
  //mb_internal_encoding("ISO-2022-JP");
132
142
 
133
- $to = mb_encode_mimeheader($to,"ISO-2022-JP")."<$to>";
143
+ $to = $_POST['email'];
134
-
144
+
135
- $title ="This is test";
145
+ $title ="test";
146
+
136
-
147
+ $body ="test";
148
+
137
- $headers = "From: ".$from;
149
+ $header = "From:";
138
-
150
+
139
- $pfrom = "-f$from";
151
+ $from = "test"; //$from
140
-
152
+
153
+
154
+
141
- $rslt = mb_send_mail($to, $title, $body, $headers, $pfrom);
155
+ $result = mb_send_mail($to, $title, $body, $header, $from);
142
-
143
-
144
-
156
+
157
+   
158
+
145
- return true;
159
+   return $result;
146
-
147
-
148
-
160
+
161
+
162
+
149
- }
163
+ }
164
+
165
+
166
+
167
+
168
+
169
+ ?>
170
+
171
+
172
+
173
+ <h2>Register your information</h2>
174
+
175
+ <form method="POST" action="register.php">
176
+
177
+ Fastname:<input type="text" name="firstname"><br><br>
178
+
179
+ Lastname:<input type="text" name="lastname"><br><br>
180
+
181
+ Email Adrress:<input type="text" name="email"><br><br>
182
+
183
+ Phone Number:<input type="text" name="phone"><br><br>
184
+
185
+ Birth Date:<input type="text" name="birthdate"><br><br>
186
+
187
+ Username:<input type="text" name="username"><br><br>
188
+
189
+ Password:<input type="text" name="password"><br><br>
190
+
191
+ <input type="submit" name="register" value="Register">
192
+
193
+ </form>
194
+
195
+
196
+
197
+ </body>
150
198
 
151
199
 
152
200
 
153
- ?>
154
-
155
-
156
-
157
- <h2>Register your information</h2>
158
-
159
- <form method="POST" action="register.php">
160
-
161
- Fastname:<input type="text" name="firstname"><br><br>
162
-
163
- Lastname:<input type="text" name="lastname"><br><br>
164
-
165
- Email Adrress:<input type="text" name="email"><br><br>
166
-
167
- Phone Number:<input type="text" name="phone"><br><br>
168
-
169
- Birth Date:<input type="text" name="birthdate"><br><br>
170
-
171
- Username:<input type="text" name="username"><br><br>
172
-
173
- Password:<input type="text" name="password"><br><br>
174
-
175
- <input type="submit" name="register" value="Register">
176
-
177
- </form>
178
-
179
-
180
-
181
- </body>
182
-
183
-
184
-
185
201
  </html>
186
202
 
187
203
  コード

1

Function send_mailを追加しました。メール送信機能。

2019/05/18 08:52

投稿

amaturePy
amaturePy

スコア131

test CHANGED
File without changes
test CHANGED
@@ -120,61 +120,35 @@
120
120
 
121
121
  };
122
122
 
123
- //////////////////////////////////////////////////////////////////////activiation of user account
124
-
125
- if(!isset($_POST)) {
126
-
127
- //$db_handle = new DBController();
128
-
129
- $query = "SELECT * FROM users where email = '" . $_POST["email"] . "'";
130
-
131
- $count = $db_handle->numRows($query);
123
+ function Send_Mail($to, $from, $title, $body){
132
124
 
133
125
 
134
126
 
135
- if($count==0) {
127
+ // メール送信
136
128
 
137
- $current_id = $db_handle->insertQuery($query);
129
+ //mb_language('ja');
138
130
 
139
- if(isset($email)) {
131
+ //mb_internal_encoding("ISO-2022-JP");
140
132
 
141
- $link="http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"."acti.php?id=" . $email;
133
+ $to = mb_encode_mimeheader($to,"ISO-2022-JP")."<$to>";
142
134
 
143
- $to =$_POST["email"];
135
+ $title ="This is test";
144
136
 
145
- $subject = "User Registration Activation Email";
137
+ $headers = "From: ".$from;
146
138
 
147
- $content = "Click this link to activate your account. <a href='" . $link . "'>" . $link . "</a>";
139
+ $pfrom = "-f$from";
148
140
 
149
- $headers = "From: kentotamu@gmail.com\r\n";
141
+ $rslt = mb_send_mail($to, $title, $body, $headers, $pfrom);
150
142
 
151
-
152
143
 
153
- if(mb_send_mail($to, $subject, $content, $headers)) {
154
144
 
155
- echo "You have registered and the activation mail is sent to your email. Click the activation link to activate you account.";
145
+ return true;
156
146
 
157
- echo "success";
158
147
 
159
- }
160
148
 
161
- //unset($_POST);
149
+ }
162
150
 
163
- } else {
151
+
164
-
165
- echo "Problem in registration. Try Again!";
166
-
167
- }
168
-
169
- } else {
170
-
171
- $message = "User Email is already in use.";
172
-
173
- //$type = "error";
174
-
175
- }
176
-
177
- }
178
152
 
179
153
  ?>
180
154