ログインフォームがあるindex.phpページがあります。
Index.php:
<?php include_once("include/header.php");?>
</head>
<body>
<div class="mainContainer">
<div class="header"><!--Header start-->
<!--Inlcluding Login Barr-->
<?php include("include/loginBar.php");?>
<div class="clear"></div>
</div><!--Header end-->
<div class="centerContent"><!--Center content start-->
</div><!--center content end-->
<div class="clear"></div>
<?php include("include/footer.php");?>
</div>
</body>
</html>
header.php:
<?php session_start();
ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" href="css/mainStylesheet.css" rel="stylesheet" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
フッター.php
<? ob_end_flush(); ?>
loginBar.php
<div class="loginBar">
<form name="Login" id="Login" action="actions.php" method="post">
<span class="label">Login</span>
<input type="text" name="name" id="username" value="Username" onBlur="if(this.value==''){this.value=this.defaultValue;}" onFocus="if(this.value==this.defaultValue){this.value='';}" />
<input type="password" name="password" id="userpassword" value="Password" onBlur="if(this.value==''){this.value=this.defaultValue;}" onFocus="if(this.value==this.defaultValue){this.value='';}"/>
<input class="loginButton" id="loginButton" type="submit" value="Go" />
<input type="hidden" value="loginValues" name="login" id="login"/>
</form>
</div>
アクション.php
<?php session_start();
echo $_POST['name']; echo $_POST['password'];
if(isset($_POST['login']) && $_POST['login']=="loginValues"){
echo "HAHAHAHAHA";
}
?>
問題は、フォームの値が actions.php ページの IF ブロックの外側にエコーされることですが、このブロック内では何も機能しません。これは、フォームの値が正常に転送されたことを意味します。
Firebug コンソールに、「HTML ドキュメントの文字エンコーディングが宣言されていません。ドキュメントに US-ASCII 範囲外の文字が含まれている場合、一部のブラウザ設定では、ドキュメントが文字化けしたテキストでレンダリングされます。」というエラーが表示されます。ページは、ドキュメントまたは転送プロトコルで宣言する必要があります。」
すべてのオプションを試し、この行を HEAD tag :
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
の後に配置しましたが、何も機能しません。
私を助けてください。ありがとう。