<?php
session_start();
header("Content-type:text/html;charset=utf-8");
$link = mysqli_connect('localhost','123654lgh', 'etjyr2bm','123654lgh');
if (!$link) {
die("连接失败:".mysqli_connect_error());
}
$sql = "로그인에서 * 선택";
$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 == "" || $ 확인 == "" || $email == "")
if ((strlen($username) < 3)||(!preg_match('/^w+$/i', $username)))
{
echo "<script>alert('信息不能为写');window.location.href='zhuce.html'</script>";
} elseif ((strlen($username ) < 3)||(!preg_match('/^w+$/i', $username))) {
echo "<script>alert('사용户name至少3位且不含不字符! ');window.location.href='zhuce'</script>";
//判断用户name长島
}elseif(strlen($password) < 5){
echo "<script> Alert('密码至少5位! 새로운填写');window.location.href='zhuce.html'</script>";
//判断密码长島
}elseif($password != $confirm) {…是否상동
} elseif (!preg_match('/^[w.]+@w+.w+$/i', $email))
echo "<script>alert('邮箱不합법! 重新填写') ;window.location.href='zhuce.html'</script>";
//判断邮箱格式是否합법
elseif(mysqli_fetch_array(mysqli_query($link,"select * from login where username = '$username) '"))){
echo "<script>alert('用户name已存재');window.location.href='zhuce.html'</script>";
} else{
$ sql= "로그인에 삽입(사용자 이름, 비밀번호, 확인, 이메일)값('$username','$password','$confirm','$email')";
//插入数据库
if(! (mysqli_query($link,$sql))){
echo "<script>alert('데이터 삽입 실패');window.location.href='zhuce.html'";
}else{
echo "<script>alert('등록 성공'); window.location.href='yonghu.html'</script>";
}
}
?>