php注册问题 ,能提交到到数据库中,但不提示注册成功
<?phpsession_start();include("conn/conn.php");$name=$_POST[usernc];$pwd1=$_POST[p1];$...
<?php
session_start();
include("conn/conn.php");
$name=$_POST[usernc];
$pwd1=$_POST[p1];
$pwd=md5($_POST[p1]);
$email=$_POST[email];
$truename=$_POST[truename];
$sfzh=$_POST[sfzh];
$tel=$_POST[tel];
$qq=$_POST[qq];
if($_POST[ts1]==1)
{
$tishi=$_POST[ts2];
}
else
{
$tishi=$_POST[ts1];
}
$huida=$_POST[tsda];
$dizhi=$_POST[dizhi];
$youbian=$_POST[yb];
$regtime=date("Y-m-j");
$dongjie=0;
$sql=mysql_query("select * from tb_user where name='".$name."'",$conn);
$info=mysql_fetch_array($sql);
if($info==true)
{
echo "<script language='javascript'>alert('该昵称已经存在!');history.back();</script>";
exit;
}
else
{
mysql_query("insert into tb_user (name,pwd,dongjie,email,truename,sfzh,tel,qq,tishi,huida,dizhi,youbian,regtime,pwd1) values ('$name','$pwd','$dongjie','$email','$truename','$sfzh','$tel','$qq','$tishi','$huida','$dizhi','$youbian','$regtime','$pwd1')",$conn);
session_register("username");
$username=$name;
session_register("producelist");
$producelist="";
session_register("quatity");
$quatity="";
echo "<script language='javascript'>alert('恭喜,注册成功!');window.location='index.php';</script>";
}
?> 展开
session_start();
include("conn/conn.php");
$name=$_POST[usernc];
$pwd1=$_POST[p1];
$pwd=md5($_POST[p1]);
$email=$_POST[email];
$truename=$_POST[truename];
$sfzh=$_POST[sfzh];
$tel=$_POST[tel];
$qq=$_POST[qq];
if($_POST[ts1]==1)
{
$tishi=$_POST[ts2];
}
else
{
$tishi=$_POST[ts1];
}
$huida=$_POST[tsda];
$dizhi=$_POST[dizhi];
$youbian=$_POST[yb];
$regtime=date("Y-m-j");
$dongjie=0;
$sql=mysql_query("select * from tb_user where name='".$name."'",$conn);
$info=mysql_fetch_array($sql);
if($info==true)
{
echo "<script language='javascript'>alert('该昵称已经存在!');history.back();</script>";
exit;
}
else
{
mysql_query("insert into tb_user (name,pwd,dongjie,email,truename,sfzh,tel,qq,tishi,huida,dizhi,youbian,regtime,pwd1) values ('$name','$pwd','$dongjie','$email','$truename','$sfzh','$tel','$qq','$tishi','$huida','$dizhi','$youbian','$regtime','$pwd1')",$conn);
session_register("username");
$username=$name;
session_register("producelist");
$producelist="";
session_register("quatity");
$quatity="";
echo "<script language='javascript'>alert('恭喜,注册成功!');window.location='index.php';</script>";
}
?> 展开
3个回答
展开全部
echo "<script language='javascript'>alert('该昵称已经存在!');history.back();</script>";
exit;
把上面的exit;去掉,你执行到这已经退出程序,后面的注册成功肯定不会再执行
exit;
把上面的exit;去掉,你执行到这已经退出程序,后面的注册成功肯定不会再执行
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1、判断有没有重复的用户名,应该去判断查询结果是否为空:mysql_num_rows,而不是使用mysql_fetch_array
2、插入语句没有去判断是否插入成功。
2、插入语句没有去判断是否插入成功。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
mysql_query("insert into tb_user (name,pwd,dongjie,email,truename,sfzh,tel,qq,tishi,huida,dizhi,youbian,regtime,pwd1) values ('$name','$pwd','$dongjie','$email','$truename','$sfzh','$tel','$qq','$tishi','$huida','$dizhi','$youbian','$regtime','$pwd1')",$conn);
这里改成
if(mysql_query("插入语言"))
{
}
这里改成
if(mysql_query("插入语言"))
{
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询