页面代码:
<!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('标题不能为空');window.localhost.href='zeng.php'";
}
$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('祝福语发布成功');window.localhost.href='zeng.php'
if(mysql_query($insertsql)){
echo"alert('祝福语发布成功');window.localhost.href='zeng.php'";
}else
{
echo"alert('祝福语发布失败');window.localhost.href='zeng.php'";
}
?>
数据库连接代码:
<?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>