php页面显示乱码,编辑器都是用的UTF-8

页面代码:
<!DOCTYPE html>



写祝福语
管理祝福语















        <tr>
            <td> <input type="submit" name="submit" id="button" value="提交内容"/>
        </tr>
    </table>
</form>


数据处理代码:
<?php
header("Content-type: text/html; charset=utf-8");
require('../wx/connect.php');
//把信息入库,在入库之前对所有的信息进行校验
if(!(isset($_POST['title'])&&(!empty($_POST['title'])))){
echo"alert(&#39;标题不能为空&#39;);window.localhost.href=&#39;zeng.php&#39;";
}

$title = $_POST['title'];
$description = $_POST['description'];
$content = $_POST['content'];
$dateline = time();
$insertsql ="insert into article(title,description,content,dateline) values('$title','$description','$content',$dateline)";

// echo $insertsql;
//alert(&#39;祝福语发布成功&#39;);window.localhost.href=&#39;zeng.php&#39;
if(mysql_query($insertsql)){
echo"alert(&#39;祝福语发布成功&#39;);window.localhost.href=&#39;zeng.php&#39;";
}else
{
echo"alert(&#39;祝福语发布失败&#39;);window.localhost.href=&#39;zeng.php&#39;";
}
?>

数据库连接代码:
<?php
header("Content-type:text/html; charset=UTF-8");
$mysql_server_name='localhost:3306';
$mysql_username='root';
$mysql_password='123456';
$mysql_database='content';

    数据:

<?php
header("Content-type:text/html; default_charset=UTF-8");
require_once('../wx/config.php');
if(!($con = mysql_connect($mysql_server_name,$mysql_username,$mysql_password))){
echo mysql_error();
}
if(!mysql_select_db($mysql_database)){
echo mysql_error();
}
if(!mysql_query("set names 'utf8'")){
echo mysql_error();
}
mysql_close($con);

标题:
简介:
内容:

先纯html页要用meta标签声明编码

有php输出的页要使用header函数声明编码
header("Content-Type:text/html; charset=gb2312");
同时文件也要另存为utf-8格式~~GBK同理

这样编码算统一了 还要注意一点 用POST传递数据 如果网站都是统一UTF8编码的话 传递中文没有问题 否则传递中文时要用urlencode函数进行编码 GET方式传输中文 无论是否为UTF8编码 都需要进行urlencode编码

缓存技术要用到memcache 可以去百度一下 很多资料

<!DOCTYPE html>