Skip to content

Instantly share code, notes, and snippets.

@hrdtbs
Last active December 22, 2017 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrdtbs/4b76077cf8f168d7c7754e4073616326 to your computer and use it in GitHub Desktop.
Save hrdtbs/4b76077cf8f168d7c7754e4073616326 to your computer and use it in GitHub Desktop.
<?php
function getParams(){
$return = array();
if (isset($_GET) && is_array($_GET)) {
$return += $_GET;
}
if (isset($_POST) && is_array($_POST)) {
$return += $_POST;
}
return $return;
}
$params = getParams();
$flag = false;
if (!empty($params)) {
$message = "";
foreach ($params as $key => $value) {
$message .= $key.":".$value."<br>";
}
mb_internal_encoding("UTF-8");
$flag = mail(
example@google.com,
mb_encode_mimeheader($params["title"], 'ISO-2022-JP-MS'),
mb_convert_encoding($message, 'ISO-2022-JP-MS'), //エンコードはISO-2022-JP-MSで行う!
"content-Type: text/html; charset=\"ISO-2022-JP\";\n" //ヘッダはISO-2022-JPを指定する!
);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<?php
if($flag) {
?>
<p>再度送信してください</p>
<?php }else{?>
<p>送信ありがとうございました</p>
<?php
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment