php和数据库连接成功 但无法插入数据 200
<?phpheader("Content-Type:text/html;charset=utf8");$link=mysqli_connect('127.0.0.1','...
<?php
header("Content-Type: text/html; charset=utf8");
$link = mysqli_connect('127.0.0.1', 'root', '111447', 'test');
//$username = $_POST["username"];
//$password = $_POST["password"];
//$pwd = $_POST["pwd"];
//$tel = $_POST["tel"];
//$email = $_POST["email"];
//$qq = $_POST["qq"];
//$yzm = $_POST["yzm"];
if (!$link) {
die('Could not connect: ' . mysql_error());
}else {
if (isset($_POST['submit'])){
if($_POST['username']==""||$_POST['password']==""||$_POST['pwd']==""){
echo "<script>alert('请输入用户名或密码!');history.go(-1);</script>";
}else
if($_POST['username']==""||$_POST['password']==""||$_POST['pwd']==""||$_POST['tel']==""||$_POST['email']==""||$_POST['qq']==""||$_POST['yzm']==""){
echo "<script>alert('请输入完整信息!');history.go(-1);</script>";
}else
if ($_POST['password'] == $_POST['pwd']){
$query = "insert into register(username,password,pwd,tel,email,qq,yzm) values('{$_POST['username']}','{$_POST['password']}','{$_POST['pwd']}','{$_POST['tel']}','{$_POST['email']}','{$_POST['qq']}','{$_POST['yzm']}')";
$result=mysqli_query($link, $query);
header("Location:login.html");
}else {
echo "<script>alert('两次输入密码不一致!');history.go(-1);</script>";
}
}
}
?> 展开
header("Content-Type: text/html; charset=utf8");
$link = mysqli_connect('127.0.0.1', 'root', '111447', 'test');
//$username = $_POST["username"];
//$password = $_POST["password"];
//$pwd = $_POST["pwd"];
//$tel = $_POST["tel"];
//$email = $_POST["email"];
//$qq = $_POST["qq"];
//$yzm = $_POST["yzm"];
if (!$link) {
die('Could not connect: ' . mysql_error());
}else {
if (isset($_POST['submit'])){
if($_POST['username']==""||$_POST['password']==""||$_POST['pwd']==""){
echo "<script>alert('请输入用户名或密码!');history.go(-1);</script>";
}else
if($_POST['username']==""||$_POST['password']==""||$_POST['pwd']==""||$_POST['tel']==""||$_POST['email']==""||$_POST['qq']==""||$_POST['yzm']==""){
echo "<script>alert('请输入完整信息!');history.go(-1);</script>";
}else
if ($_POST['password'] == $_POST['pwd']){
$query = "insert into register(username,password,pwd,tel,email,qq,yzm) values('{$_POST['username']}','{$_POST['password']}','{$_POST['pwd']}','{$_POST['tel']}','{$_POST['email']}','{$_POST['qq']}','{$_POST['yzm']}')";
$result=mysqli_query($link, $query);
header("Location:login.html");
}else {
echo "<script>alert('两次输入密码不一致!');history.go(-1);</script>";
}
}
}
?> 展开
10个回答
展开全部
建议你在执行插入语句之前执行
mysqli_query($link,"set names 'utf8'");
还有mysql_error改成mysqli_error
实在不行把报的错截个图
mysqli_query($link,"set names 'utf8'");
还有mysql_error改成mysqli_error
实在不行把报的错截个图
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<?phpmysql_connect("localhost","root","111")or die("数据库连接失败");mysql_select_db("xiongwei")or die ("连接失败");mysql_set_charset("gbk");if(!empty($_POST['submit']))
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
","root","111")or die("数据库连接失败");mysql_select_db("xiongwei")or die ("连接失败");mysql_set_charset("gbk");if(!empty($_POST['submit']))
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |