1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
<?php ini_set("SMTP","smtp.xxx.com"); ini_set("smtp_port","587"); //ini_set("display_errors","On"); //ini_set("error_reporting",E_ALL); mb_language("japanese"); mb_internal_encoding("UTF-8"); session_start(); //if(!array_key_exists("t",$_SESSION)) $_SESSION["t"] = uniqid(); if(!array_key_exists("k",$_POST)) $_SESSION["t"] = uniqid(); echo '<form method="POST">'; echo 'お名前:<input name="n" type="text"><br>'; echo 'メールアドレス:<input name="m" type="text"><br>'; echo '件名:<input name="s" type="text"><br>'; echo '本文<textarea name="b"></textarea><br>'; echo '<input type="submit" value="送信">'; echo '<input name="k" type="hidden" value="' . $_SESSION["t"] . '">'; echo '</form>'; if(array_key_exists("k",$_POST) && array_key_exists("t",$_SESSION) && $_POST["k"] === $_SESSION["t"]){ mb_send_mail("mail@xxx.com",$_POST["s"],$_POST["b"],"From:mail@xxx.com"); $_SESSION["t"] = uniqid(); echo '<script>(function(){alert("お問い合わせを受け付けました。");})();</script>'; } ?> |