お問い合わせフォームのcontact_verify.php(確認ページ)をブラウザで見ると、インクルードされたheader.php(ヘッダー部分)が表示されず勝手にコメントアウトされている。
元々htmで作られたcontact_verify.htm を全ページ共通でheader.phpを読み込ませるために全ページをhtmlからphp化していますが、確認ページだけheader.phpが表示されません。ブラウザでインクルードされたphpが勝手にコメントアウトされる原因はどのようなことが考えられますでしょうか。
■ページ構成
index.php(お問い合わせフォーム)
header.php(全ページ共通のメタ、ヘッダー部分)をindex.phpの中にインクルードしている
toiawase.php(確認ページ、サンキューページ、メール来ました等のsendmail、postの設定)
contact_verify.php(確認ページ)
■index.phpの中身(抜粋)とcontact_verify.php(確認ページ)の以下記述は同じです。
※index.phpはheader.phpが表示されていますが、確認ページでは表示されません。
ちなみに、require_once をincludeやrequireにしても確認ページだけ表示されず、ブラウザのソースを見ると勝手にコメントアウトされています。
■toiawase.phpの中身(抜粋)
$verifypage = "contact_verify.php"; // ----- Output to Web. if ($_POST['sendmail'] == "1") { $htmlfile = $thxpage; } else { $htmlfile = $verifypage; print replaceMsg (@file_get_contents($htmlfile)); exit(); } // ----- to redirect to thanks page. session_destroy(); header ("Location: " . $htmlfile); }
■追記します。
// ----- Send Email if ($_POST['sendmail'] == "1") { reset ($_POST); $emailhead = 'From: ' . $emailfrom; $emailmsg = @file_get_contents($email_clr); $emailmsg = setDate ($emailmsg); $emailmsg = getEnvData ($emailmsg); $emailmsg = replaceMsg ($emailmsg); $emailmsg = htmlspecialchars_decode($emailmsg); mb_send_mail ($emailto, $subject_clr, $emailmsg, $emailhead); // ----- to Visitor. reset ($_POST); $emailhead = 'From: ' . $emailfrom; $emailenv = '-f' . $emailfrom; $emailmsg = @file_get_contents($email_thx); $emailmsg = setDate ($emailmsg); $emailmsg = replaceMsg ($emailmsg); $emailmsg = htmlspecialchars_decode($emailmsg); mb_send_mail ($email, $subject_thx, $emailmsg, $emailhead, $emailenv); // ----- to redirect to thanks page. session_destroy(); header ("Location: " . $htmlfile); } } // ----- func: replace message function replaceMsg ($msgdata) { global $_POST; reset ($_POST); for ( $loop = 1; $loop <= count($_POST); $loop++ ) { $postkey = key($_POST); $multiple = count($_POST[$postkey]); if ( is_array ($_POST[$postkey]) ) { $value = ""; $multiple --; for ( $mloop = 0; $mloop <= $multiple; $mloop++ ) { $value = $value . $_POST[$postkey][$mloop] . ', '; } $value = rtrim ($value, ", "); } else { $value = current($_POST); $_POST[$postkey] = current($_POST); } if ( preg_match("/email/i", $postkey) || ($postkey == "メールアドレス") ) { global $email; $email = $value; } $value = htmlspecialchars($value); // print "postkey: $postkey / multiple: $multiple / value: $value <br>"; $keyword = "##__" . $postkey . "__##"; $msgdata = str_replace($keyword, $value, $msgdata); next($_POST); } $msgdata = preg_replace ("/##__.+__##/", "", $msgdata); $msgdata = mb_convert_kana($msgdata,"KV"); return $msgdata; }
回答3件
あなたの回答
tips
プレビュー