',">", $mixed); return $mixed; } if (empty($_REQUEST["mode"])){ top(); exit; } if ($_REQUEST["mode"] == "confirm"){ confirm(); }else if($_REQUEST["mode"] == "complete"){ complete(); }else{ top(); } function top(){ $BaseHtm = file_get_contents("temp_question.html"); print $BaseHtm; exit; } function confirm(){ session_start(); $_SESSION['name'] = $_REQUEST["name"]; $_SESSION['add_1'] = $_REQUEST["add_1"]; $_SESSION['mail_1'] = $_REQUEST["mail_1"]; $_SESSION['comment'] = $_REQUEST["comment"]; //入力内容のチェック checkData($dbc,$util,"new"); $BaseHtm = file_get_contents("temp_confirm_ok.html"); $BaseHtm = str_replace('$name$', $_SESSION['name'], $BaseHtm); $BaseHtm = str_replace('$add_1$', $_SESSION['add_1'], $BaseHtm); $BaseHtm = str_replace('$mail_1$', $_SESSION['mail_1'], $BaseHtm); $BaseHtm = str_replace('$comment$', nl2br($_SESSION['comment']), $BaseHtm); $uniq_id = md5(uniqid(rand(),1)); $BaseHtm = str_replace('$uniq_id$' ,$uniq_id, $BaseHtm); $_SESSION['standby'] = "1"; $_SESSION['uniq_id'] = $uniq_id; setcookie('uniq_id', $uniq_id); print $BaseHtm; exit; } function complete(){ session_start(); if($_POST['u'] == "") exit; if($_POST['u'] != $_SESSION['uniq_id']) exit; if($_POST['u'] != $_COOKIE['uniq_id']) exit; // メール送信先を指定します。 $to = "infomation_e@kanetoku.co.jp"; //$to = "e_kanazawa@admics.co.jp"; $from = "infomation_e@kanetoku.co.jp"; // フォームの値を取得します。 if ($_SERVER["REQUEST_METHOD"] != "POST") { exit(); } mb_internal_encoding("sjis"); mb_language("japanese"); $title2 = "HPよりお問合せ"; $naiyou2 = "NAME   :".$_SESSION["name"]. "\n"; $naiyou2 .= "Address  :".$_SESSION["add_1"]. "\n"; $naiyou2 .= "E-mail  :".$_SESSION["mail_1"]. "\n"; $naiyou2 .= "Message  :".$_SESSION["comment"]. "\n"; $addHeader .= "From: $from\n"; if ($_SESSION['standby'] == "1"){ $isSuc = mb_send_mail($to,$title2,$naiyou2,$addHeader); if ($isSuc){ echo ""; } else { echo "メール送信失敗です"; } } $_SESSION['standby'] = "0"; $BaseHtm = file_get_contents("temp_complete.html"); print $BaseHtm; exit; } function checkData($dbc,$util,$mode){ $err = 0; $BaseHtm = file_get_contents("temp_confirm_ng.html"); //担当者 if ($_REQUEST["name"] == ""){ $err++; $BaseHtm = str_replace('$name$', "Inputting error", $BaseHtm); } //メールアドレス if ($_REQUEST["mail_1"] == ""){ $err++; $BaseHtm = str_replace('$mail_1$', "Inputting error", $BaseHtm); } //問合せ if ($_REQUEST["comment"] == ""){ $err++; $BaseHtm = str_replace('$comment$', "Inputting error", $BaseHtm); } if ($err > 0){ $BaseHtm = str_replace('$name$', $_REQUEST['name'], $BaseHtm); $BaseHtm = str_replace('$add_1$', $_REQUEST['add_1'], $BaseHtm); $BaseHtm = str_replace('$mail_1$', $_REQUEST['mail_1'], $BaseHtm); $BaseHtm = str_replace('$comment$', nl2br($_REQUEST['comment']), $BaseHtm); print $BaseHtm; exit; }else{ $BaseHtm = null; } } //----------------------------------------------------------------------------- //戻り値:OK=true,NG=false //----------------------------------------------------------------------------- function mailcheck($email){ if(preg_match('/^(?:[^(\040)<>@,;:".\\\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\\\[\]\000-\037\x80-\xff])|"[^\\\\\x80-\xff\n\015"]*(?:\\\\[^\x80-\xff][^\\\\\x80-\xff\n\015"]*)*")(?:\.(?:[^(\040)<>@,;:".\\\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\\\[\]\000-\037\x80-\xff])|"[^\\\\\x80-\xff\n\015"]*(?:\\\\[^\x80-\xff][^\\\\\x80-\xff\n\015"]*)*"))*@(?:[^(\040)<>@,;:".\\\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\\\x80-\xff\n\015\[\]]|\\\\[^\x80-\xff])*\])(?:\.(?:[^(\040)<>@,;:".\\\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\\\x80-\xff\n\015\[\]]|\\\\[^\x80-\xff])*\]))*$/',$email)){ return false; }else{ return true; } } ?>