文件名称:页面的开发
文件大小:461B
文件格式:PHP
更新时间:2017-06-23 18:13:14
setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$bd->setAttribute(PDO::ATTR_PERSISTENT,true);
$bd ->query("set names gbk");//改变保存数据编码格式
$username=$_POST["username"];
$age=$_POST["age"];
$school=$_POST["school"];
$address=$_POST["address"];
$insertSql="insert into t_user(username,age,school,address) value('$username', ' $age' ,'$school', '$address')";
echo $insertSql."
";
$result=$bd->exec($insertSql);
if($result){
echo "添加成功";
header("Location:xiangmu.php");
}else{
echo "添加失败";
}
?>