各大神帮帮忙,如何解决这个乱码有关问题

WBOY
Release: 2016-06-13 12:10:21
Original
889 people have browsed it

各大神帮帮忙,怎么解决这个乱码问题
这是前面部分
header("Content-Type:text/html;charset=utf-8");
?>

<script></script>

<script><br /> function show(username){<br /> if(username==""){<br /> alert("用户名不能为空");<br /> return;<br /> }<br /> var ajax=Ajax();<br /> var userobj=document.getElementById("userid");<br /> ajax.post("form.php",{username:username},function(data){<br /> userobj.innerHTML=data;<br /> });<br /> }<br /></script>


username:

password:


这是模拟服务器部分

header("Content-Type:text/html;charset=utf-8");

$mysqli=new mysqli("localhost","root","123456","web");

$result=$mysqli->query("select * from user where user='{$_POST["username"]}'");

if($result->num_rows > 0){
echo "用户{$_POST["username"]}已经存在,不能使用";
}else{
echo "用户{$_POST["username"]}不存在,可以使用";
}

在浏览器出现中文乱码,怎么解决呀,,,,,谢谢各位大神帮帮忙!!!!


------解决思路----------------------
你的服务端文件不是utf-8编码。改成utf-8编码应该就可以了。
------解决思路----------------------
看看你的PHP脚本文件编码格式必须是utf8才行呢
------解决思路----------------------
用编辑器保存为utf-8 无BOM头格式。
------解决思路----------------------
应该是bom头导致的
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!