利用PHP函数设置页面的头文件编码,即可,在php文件中加入如下代码:
header(“Content-Type:text/html;charset=utf-8”);
eg:
<?php
session_start();
include ‘conn.php’;
header(“Content-Type:text/html;charset=utf-8”);
$name=$_POST[‘Name’];
$pass=$_POST[‘Pass’];
$conn=new conn();
$info=$conn->findOne(“select * from Userinfo where txtId='{$name}’ and txtPass='{$pass}'”);
if(empty($info)){
    echo (“<script language=JavaScript>{window.alert(‘输入的账户或密码错误,请重新输入!’);window.location.href=’index.php’;}</script>”);
    exit;
}
setcookie(‘adminok’,true,time()+864000,”/”);
$_SESSION[“txtClass”]=$name;
$_SESSION[“tg”]=$info[‘tg’];
$_SESSION[‘uid’]=$info[‘id’];
header(“location:/log.php”);
exit;