写了个简单的注册页面,可填完表单,点击提交,页面没有反应解决方法
程序员文章站
2024-01-13 11:26:04
...
写了个简单的注册页面,可填完表单,点击提交,页面没有反应
填完表单,点击提交,页面没有反应
代码:
register page
if(!empty($_POST['submit']))
{
$username=$_POST['username'];
$password=$_POST['password'];
$verify_ps=$_POST['verify_ps'];
$email=$_POST['email'];
$qq=$_POST['qq'];
}
if(!isset($_POST['username'],$_POST['password'],$_POST['verify_ps'],$_POST['email']))
{
?>
}
else{
$mysql=new mysqli('localhost','webuser','123456');
if(!$mysql)
{
echo "can't connect to db.";
exit;
}
$select=$mysql->select_db('user',$mysql);//设定与链接标识符(这里是$mysql)相关联的当前激活数据库
if(empty($select))
{
die("can't select to db.");
}
$s_username="select name='".$username."'from picuser";
$s_email="select e_mail='".$email."'from picuser";
$name_result=$mysql->query($s_username);
$email_result=$mysql->query($s_email);
$n_row=$name_result->fetch_row();
$e_row=$email_result->fetch_row();
if($n_row||$e_row){
echo "this username has been registered." ;
exit;
}
$insert_user="insert into picuser(name,password,e_mail,qq) values ('".$username."','".$password."','".$email."','".$qq."')";
$insert_result=$mysql->query($insert_user);
if($insert_result)
{
die('insert data is fail.');
}else{
echo "you has registered successful!";
}
}
?>
------解决方案--------------------
表单写规范点啦。
填完表单,点击提交,页面没有反应
代码:
if(!empty($_POST['submit']))
{
$username=$_POST['username'];
$password=$_POST['password'];
$verify_ps=$_POST['verify_ps'];
$email=$_POST['email'];
$qq=$_POST['qq'];
}
if(!isset($_POST['username'],$_POST['password'],$_POST['verify_ps'],$_POST['email']))
{
?>
}
else{
$mysql=new mysqli('localhost','webuser','123456');
if(!$mysql)
{
echo "can't connect to db.";
exit;
}
$select=$mysql->select_db('user',$mysql);//设定与链接标识符(这里是$mysql)相关联的当前激活数据库
if(empty($select))
{
die("can't select to db.");
}
$s_username="select name='".$username."'from picuser";
$s_email="select e_mail='".$email."'from picuser";
$name_result=$mysql->query($s_username);
$email_result=$mysql->query($s_email);
$n_row=$name_result->fetch_row();
$e_row=$email_result->fetch_row();
if($n_row||$e_row){
echo "this username has been registered." ;
exit;
}
$insert_user="insert into picuser(name,password,e_mail,qq) values ('".$username."','".$password."','".$email."','".$qq."')";
$insert_result=$mysql->query($insert_user);
if($insert_result)
{
die('insert data is fail.');
}else{
echo "you has registered successful!";
}
}
?>
------解决方案--------------------
表单写规范点啦。