session_start();
header("Content-type:text/html;charset=utf-8");
$link = mysqli_connect('localhost','123654lgh','etjyr2bm','123654lgh');
if (!$link) {
die("连接失败:".mysqli_connect_error());
}
$sql = "select * from login";
$result = mysqli_query($link, $sql);
$rows = mysqli_fetch_array($result);
$username = $_POST['username'];
$password = $_POST['password'];
$confirm = $_POST['confirm'];
$email = $_POST['email'];
if($username == "" || $password == "" || $confirm == "" || $email == "")
if ((strlen($username) < 3)||(!preg_match('/^\w+$/i', $username)))
{
echo "";
} elseif ((strlen($username) < 3)||(!preg_match('/^\w+$/i', $username))) {
echo "";
//判断用户名长度
}elseif(strlen($password) < 5){
echo "";
//判断密码长度
}elseif($password != $confirm) {
echo "";
//检测两次输入密码是否相同
} elseif (!preg_match('/^[\w\.]+@\w+\.\w+$/i', $email))
echo "";
//判断邮箱格式是否合法
elseif(mysqli_fetch_array(mysqli_query($link,"select * from login where username = '$username'"))){
echo "";
} else{
$sql= "insert into login(username, password, confirm, email)values('$username','$password','$confirm','$email')";
//插入数据库
if(!(mysqli_query($link,$sql))){
echo "";
}
}
?>
这是客户端的提示,你页面上用表单提交了,然后你刷新就会有的提示,不是的代码报错问题