php数据库写入问题!!!!
我把表单的内容提交到相应的页面进行处理.然后写入数据库.可是什么写不进去呀.mysql里面不加数据.而处理页面又没有任何提示啊.处理页面的代码:<?include"con...
我把表单的内容提交到相应的页面进行处理.然后写入数据库.可是什么写不进去呀.mysql里面不加数据.而处理页面又没有任何提示啊.
处理页面的代码:
<?
include "conn/conn.php";
$UserName=$_POST[UserName];
$mima1=$_POST[mima1];
$mima2=$_POST[mima2];
$xin=$_POST[xin];
$nian=$_POST[nian];
$dianhua=$_POST[dianhua];
$email=$_POST[email];
$qq=$_POST[qq];
$sql="INSERT INTO 'my_china'.'chuche' ('id','UserName' ,'mima1' ,'mima2' ,'xin' ,'nian' ,'dianhua' ,'email' ,'qq' )VALUES (NULL , '$UserName', '$mima1', '$mima2', '$xin', '$nian', '$dianhua', '$email', '$qq')";
mysql_query($sql);
echo "<script> alert('用户注册成功!');</script>";
echo "<script> window.location='zc.php';</script>";
?>
以前我不申明表单的名字(name)直接放入mysql写入语句.能写入mysql.但是写入的全是空白.什么内容都没.只是id在增加.其它全空白.现在用这种方法写入.根本就写不进去了..
我的mysql版本:phpmyadmin 2.11.1 展开
处理页面的代码:
<?
include "conn/conn.php";
$UserName=$_POST[UserName];
$mima1=$_POST[mima1];
$mima2=$_POST[mima2];
$xin=$_POST[xin];
$nian=$_POST[nian];
$dianhua=$_POST[dianhua];
$email=$_POST[email];
$qq=$_POST[qq];
$sql="INSERT INTO 'my_china'.'chuche' ('id','UserName' ,'mima1' ,'mima2' ,'xin' ,'nian' ,'dianhua' ,'email' ,'qq' )VALUES (NULL , '$UserName', '$mima1', '$mima2', '$xin', '$nian', '$dianhua', '$email', '$qq')";
mysql_query($sql);
echo "<script> alert('用户注册成功!');</script>";
echo "<script> window.location='zc.php';</script>";
?>
以前我不申明表单的名字(name)直接放入mysql写入语句.能写入mysql.但是写入的全是空白.什么内容都没.只是id在增加.其它全空白.现在用这种方法写入.根本就写不进去了..
我的mysql版本:phpmyadmin 2.11.1 展开
2个回答
展开全部
你的$_POST有问题, 原因分析,首先$_POST[UserName] ,UserName程序解释为变量,在你页面中,没有进行UserName的敷值,所以他为空,那么 $_POST[UserName] 就= $_POST[""] 那么结果当然是空了!
<?
include "conn/conn.php";
$UserName=$_POST["UserName"];
$mima1=$_POST["mima1"];
$mima2=$_POST["mima2"];
$xin=$_POST["xin"];
$nian=$_POST["nian"];
$dianhua=$_POST["dianhua"];
$email=$_POST["email"];
$qq=$_POST["qq"];
$sql="INSERT INTO 'my_china'.'chuche' ('id','UserName' ,'mima1' ,'mima2' ,'xin' ,'nian' ,'dianhua' ,'email' ,'qq' )VALUES (NULL , '$UserName', '$mima1', '$mima2', '$xin', '$nian', '$dianhua', '$email', '$qq')";
mysql_query($sql);
echo "<script> alert('用户注册成功!');</script>";
echo "<script> window.location='zc.php';</script>";
?>
<?
include "conn/conn.php";
$UserName=$_POST["UserName"];
$mima1=$_POST["mima1"];
$mima2=$_POST["mima2"];
$xin=$_POST["xin"];
$nian=$_POST["nian"];
$dianhua=$_POST["dianhua"];
$email=$_POST["email"];
$qq=$_POST["qq"];
$sql="INSERT INTO 'my_china'.'chuche' ('id','UserName' ,'mima1' ,'mima2' ,'xin' ,'nian' ,'dianhua' ,'email' ,'qq' )VALUES (NULL , '$UserName', '$mima1', '$mima2', '$xin', '$nian', '$dianhua', '$email', '$qq')";
mysql_query($sql);
echo "<script> alert('用户注册成功!');</script>";
echo "<script> window.location='zc.php';</script>";
?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询