PHP user registration login system registration processing page
Registration processing page
The code is as follows:
alert('请确认信息完整性!'); history.go(-1);"; } else { if($psw == $psw_confirm) { $conn = mysqli_connect("localhost","root","root"); //连接数据库,帐号密码为自己数据库的帐号密码 if(mysqli_errno($conn)){ echo mysqli_error($conn); exit; } mysqli_select_db($conn,"userdb"); //选择数据库 mysqli_set_charset($conn,'utf8'); //设定字符集 $sql = "select username from user where username = '$user'"; //SQL语句 $result = mysqli_query($conn,$sql); //执行SQL语句 $num = mysqli_num_rows($result); //统计执行结果影响的行数 if($num) //如果已经存在该用户 { echo ""; } else //不存在当前注册用户名称 { $sql_insert = "insert into `user` (`username`,`userpwd`) values('" . $user . "','" . $psw ."')"; $res_insert = mysqli_query($conn,$sql_insert); //$num_insert = mysql_num_rows($res_insert); if($res_insert) { echo ""; } else { echo ""; } } } else { echo ""; } } } else { echo ""; } ?>
Registration page program flow chart
#