<?php
session_start();
header("Content-type:text/html;charset=utf-8") ;
$link = mysqli_connect('localhost','123654lgh','etjyr2bm','123654lgh');
if (!$link) {
die( "Connection failed:".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 "<script>alert('The message cannot be Empty! Refill');window.location.href='zhuce.html'</script>";
} elseif ((strlen($username) < 3)||(!preg_match( '/^\w $/i', $username))) {
echo "<script>alert('Username must be at least 3 digits and does not contain illegal characters! Refill');window.location .href='zhuce'</script>";
//Determine the username length
}elseif(strlen($password) < 5){
echo "<script>alert('The password must be at least 5 characters! Refill');window.location.href='zhuce.html'</script>";
//Judge password length
}elseif($password != $confirm) {
echo "<script>alert('The two passwords are different! Refill');window.location.href='zhuce.html'</script>";
//Check whether the password entered twice is the same
} elseif (!preg_match('/^[\w\.] @\w \.\w $/i', $email))
echo "<script>alert('The email is illegal! Refill');window.location.href='zhuce.html'</script>";
//Determine the email format Is it legal
elseif(mysqli_fetch_array(mysqli_query($link,"select * from login where username = '$username'"))){
echo "<script>alert('User name already exists');window.location.href='zhuce.html'</script>";
} else{
$sql= "insert into login(username, password , confirm, email)values('$username','$password','$confirm','$email')";
//Insert into the database
if(!(mysqli_query ($link,$sql))){
echo "<script>alert('Data insertion failed');window.location.href='zhuce.html'";
}else{
echo "< script>alert('Registration successful');window.location.href='yonghu.html'</script>";
}
}
?> ;
kanglecheng2019-07-12 14:22:26
This is a prompt from the client. If you submit a form on your page, then you will see the prompt when you refresh it. This is not a code error issue