亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Registration verification

The user name and password entered by the user are verified. If it is empty or the password entered twice is inconsistent, the user returns to the login page (you can also add other verifications yourself here, such as password length verification). If the verification conditions are met, connect to the database. , the database connection is correct. If the query database user name already exists, print "User already exists!" and return to the login page. If the insertion fails, print "Registration failed! Return to the login page"; if the insertion is successful, print "Registration successful! Return to the login page"

The code is as follows:

add.php

<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/2/27 0027
 * Time: 上午 11:06
 */
header('Content-type:text/html;charset=utf-8');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (empty($_POST['username'])){
        echo "<script>alert('用戶名不能為空!');location.href='login.html';</script>";
    }else {
        $username = trim($_POST['username']);
    }
    if (empty($_POST['password'])){
        echo "<script>alert('密碼不能為空!');location.href='login.html';</script>";
    }else{
        $password = $_POST['password'];
    }
    if (empty($_POST['repassword'])){
        echo "<script>alert('確認密碼不能為空!');location.href='login.html';</script>";
    }else{
        $repassword = $_POST['repassword'];
    }
    if ($password != $repassword) {
        echo "<script>alert('兩次輸入密碼不一致!');location.href='login.html';</script>";
    }
}
$mysqli = new mysqli('localhost', 'root', 'root', 'student');
$result = $mysqli->query("SELECT password FROM user WHERE username = "."'$username'");
$rs=$result->fetch_row();
if(!empty($rs)){
    echo "<script>alert('用戶已存在!');location.href='login.html';</script>";
}else {
    $mysqli = new mysqli('localhost', 'root', 'root', 'student');
    $sql = "INSERT INTO user (username,password) VALUES ('$_POST[username]', '$_POST[password]')";
    $rs = $mysqli->query($sql);
    if (!$rs) {
        echo "<script>alert('注冊失敗!');location.href='login.html';</script>";
    } else {
        echo "<script>alert('注冊成功!返回登錄頁面');location.href='login.html';</script>";
    }
}


Continuing Learning
||
<?php /** * Created by PhpStorm. * User: Administrator * Date: 2018/2/27 0027 * Time: 上午 11:06 */ header('Content-type:text/html;charset=utf-8'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (empty($_POST['username'])){ echo "<script>alert('用戶名不能為空!');location.href='login.html';</script>"; }else { $username = trim($_POST['username']); } if (empty($_POST['password'])){ echo "<script>alert('密碼不能為空!');location.href='login.html';</script>"; }else{ $password = $_POST['password']; } if (empty($_POST['repassword'])){ echo "<script>alert('確認密碼不能為空!');location.href='login.html';</script>"; }else{ $repassword = $_POST['repassword']; } if ($password != $repassword) { echo "<script>alert('兩次輸入密碼不一致!');location.href='login.html';</script>"; } } $mysqli = new mysqli('localhost', 'root', 'root', 'student'); $result = $mysqli->query("SELECT password FROM user WHERE username = "."'$username'"); $rs=$result->fetch_row(); if(!empty($rs)){ echo "<script>alert('用戶已存在!');location.href='login.html';</script>"; }else { $mysqli = new mysqli('localhost', 'root', 'root', 'student'); $sql = "INSERT INTO user (username,password) VALUES ('$_POST[username]', '$_POST[password]')"; $rs = $mysqli->query($sql); if (!$rs) { echo "<script>alert('注冊失??!');location.href='login.html';</script>"; } else { echo "<script>alert('注冊成功!返回登錄頁面');location.href='login.html';</script>"; } }
submitReset Code