LoadTemplate("inquiry.template", "UTF-8"); $tbs->escape_post(); if (formCheck(&$tbs)){ $_SESSION[inquiry] = $_POST; $tbs->LoadTemplate("inquiry2.template", "UTF-8"); } } elseif ($_POST[cmd]=="submit" && $_SESSION[inquiry][name]<>""){ $arySQL = array( "dateinserted" => date("Y/m/d H:n:s"), "name" => $_SESSION[inquiry][name], "kana" => $_SESSION[inquiry][kana], "postal" => $_SESSION[inquiry][postal], "address" => $_SESSION[inquiry][address], "email" => $_SESSION[inquiry][email], "tel" => $_SESSION[inquiry][tel], "contact" => iif($_SESSION[inquiry][contact]=="電話", "T", iif($_SESSION[inquiry][contact]=="メール", "M", "")), "comment" => $_SESSION[inquiry][comment], "hostip" => $_SERVER[REMOTE_ADDR], "hostname" => gethostbyaddr($_SERVER[REMOTE_ADDR]), ); $sql = _sql_insert("inquiry", $arySQL); mysql_query($sql) or die("sql error
$sql"); $arySQL[contact] = $_SESSION[inquiry][contact]; $mailText = _readTextFile("inquiry_confirm.mail"); $mailText = _replaceText($mailText ,$arySQL); $mailText = str_replace("
", "\n", $mailText); _sendMail("info@aoki-sports.com", $_SESSION[inquiry][email], "お問い合わせありがとうございます", $mailText); _sendMail("info@aoki-sports.com", "info@aoki-sports.com", "お問い合わせありがとうございます", $mailText); unset($_SESSION[inquiry]); $tbs->LoadTemplate("inquiry3.template", "UTF-8"); } else { $tbs->LoadTemplate("inquiry.template", "UTF-8"); } $tbs->MergeField("ErrorMessage", ""); $tbs->Show(); function formCheck($tbs){ $aryHankakuField = array( "postal", "email", ); foreach ($aryHankakuField as $key => $field){ $_POST[$field] = mb_convert_kana($_POST[$field], "a", "UTF-8"); } $aryCheckField = array( "email" => "メールアドレス", "name" => "お名前", "kana" => "ふりがな", "comment" => "コメント", ); $errField = array(); $errTitle = array(); if ($_POST[comment]=="ご自由にご記入ください"){ $_POST[comment] = ""; } if ($_POST[directMail]=="希望しない"){ $_POST[contact] = ""; } foreach ($aryCheckField as $key => $fieldTitle){ if (trim($_POST["$key"])==""){ $errField[] = $key; $errTitle[] = $fieldTitle; } } foreach ($errField as $key){ $tbs->Source = ereg_replace("\[title\.{$key}\]", " style='color:red; font-weight:bold'", $tbs->Source); } $tbs->Source = ereg_replace("\[title\.([^]]+)\]", "", $tbs->Source); if (count($errField)==0){ $tbs->MergeField("ErrorMessage", ""); } else { $tbs->MergeField("ErrorMessage", "alert('".implode("、", $errTitle)."を確認して下さい。')"); } return count($errField)==0; } function _before_loadtemplate($tbs){ $tbs->TplVars[dirRoot] = ".."; } function _after_loadtemplate($tbs){ } ?>