<?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 = "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 == "" || $ best?tigen == "" ||. $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('用戶名至少3位且不含非法字符!重新填寫');window.location.href='zhuce'</script>";
?//判斷用戶名長(zhǎng)度
?}elseif(strlen($password) < 5){
?echo "<script> Alert('密碼至少5位!重新填寫');window.location.href='zhuce.html'</script>";
?//判斷密碼長(zhǎng)度
?}elseif($password != $confirm) {
?echo "<script>alert('兩次密碼不相同!重新填寫');window.location.href='zhuce.html'</script>";
?//檢測(cè)兩次輸入密碼是否相同
?} 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('用戶名已存在');window.location.href='zhuce.html'</script>";
?} else{
?$ sql= "in die Anmeldung einfügen(Benutzername, Passwort, Best?tigung, E-Mail)Werte('$Benutzername','$Passwort','$Best?tigen','$E-Mail')";
?//插入數(shù)據(jù)庫(kù)
?if(! (mysqli_query($link,$sql))){
echo "<script>alert('Dateneinfügung fehlgeschlagen');window.location.href='zhuce.html'";
}else{
echo "<script>alert('Registrierung erfolgreich'); window.location.href='yonghu.html'</script>";
}
}
?>