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

?? ???? ??? ??? ??? PHP ?? ??

?? ????? ??? ?? ???, ??? ????, ?????? ??? ?? ?? ?? ??? ??????. ?? ????? ??? ??? ???? ????? ?? ????? ??? ?? ???? ?????!

?? login.php ??? ???? ???. ? ??? ??? ???? ?? ? ??? ???? ? ??? ? ????. ???? html ??? ??? ?? ??? php ??? ?? ??? ?? ????. ?? ??? PHP ?? ?? ??? ??? ?? ?? ??? HTML ??? ??? ? ????! ??? ??? ??? ???? ?? ????!

login.php ??? ??? ? ?? ?? ?? ? ?? ??????? ???? ????. ?? ??? ???? ???? ?? ?????!

??? ???? ?? ??? ?? ?? ? ??? ?? ???? session_start()? ????? ???. ??? ??? ?? ??? ??? ? ????. session_start()? ????.

??? ??? ????.

<?php
session_start();
// 連接mysql數(shù)據(jù)庫
$link = mysqli_connect('localhost', 'root', 'root');
if (!$link) {
    echo "connect mysql error!";
    exit();
}
// 選中數(shù)據(jù)庫 news為數(shù)據(jù)庫的名字
$db_selected = mysqli_select_db($link, 'news');
if (!$db_selected) {
    echo "<br>selected db error!";
    exit();
}
// 設(shè)置mysql字符集 為 utf8
$link->query("set names utf8");

?? ??? ??? ??? ???? ???? ????. ???? ???? ??? ??? ??? ??? ????? ???? ?? ?????. ??? ??? ?? ??????? ???? ??? ???? ?????!

<?php
$username = $_POST['username'];//獲取用戶名
$password = $_POST['password'];//獲取密碼
$code = $_POST['code'];

post? ?? ???? ???? ??? get? ?? ???? ????? ??? ??? ??? ?? ????. ??? ???? ????!

???? ???? ???? ??? ???? ??????? ???? ??? ????? ???? ???. ? ????? ???? ????? ??? ? ??? ??? ??? ? ????. ??? SQL ?? ??? ????.

<?php
if(!empty($_POST)){
    // 查詢數(shù)據(jù)庫中是否存在用戶信息
    $sql = "select * from user where username = '{$username}' and password = '{$password}'";
    $result = mysqli_query($link,$sql);
    $user = mysqli_fetch_array($result,MYSQL_ASSOC);}

Query ???? ??? ? ? ??? ??? ?????.

if($user){
    header("Location: index.php");
}else{
    echo "<script>alert('賬戶或者密碼錯誤!重新填寫')</script>";
}

???? ??? ??? ????? ?????? ?? ??? ????. ?? ??? ???? ???. ???? ?? ?? ????? ??????.

1738.png

code.zip

? ?? ?? ?? ??? ?????!

?? ?? ?? ??? ???? ???.

if(($_SESSION['authcode']) !== ($code)){               //驗證碼作對比,驗證碼頁面跟輸入的驗證碼對比
    echo "<script>alert('驗證碼錯誤!重新填寫')</script>";

??: $_SESSION['authcode'] ??? ??? ??? ???? ?? ??? ????. ??? ????? ???????!

?? ??? ??? ???????!

???? ??
||
<?php session_start(); // 連接mysql數(shù)據(jù)庫 $link = mysqli_connect('localhost', 'root', 'root'); if (!$link) { echo "connect mysql error!"; exit(); } // 選中數(shù)據(jù)庫 news為數(shù)據(jù)庫的名字 $db_selected = mysqli_select_db($link, 'news'); if (!$db_selected) { echo "<br>selected db error!"; exit(); } // 設(shè)置mysql字符集 為 utf8 $link->query("set names utf8"); if(!empty($_POST)){ $username = $_POST['username'];//獲取用戶名 $password = $_POST['password'];//獲取密碼 $code = $_POST['code']; // 查詢數(shù)據(jù)庫中是否存在用戶信息 $sql = "select * from user where username = '{$username}' and password = '{$password}'"; $result = mysqli_query($link,$sql); $user = mysqli_fetch_array($result,MYSQL_ASSOC); if(($_SESSION['authcode']) !== ($code)){ //驗證碼作對比,驗證碼頁面跟輸入的驗證碼對比 echo "<script>alert('驗證碼錯誤!重新填寫')</script>"; }elseif($user){ header("Location: index.php"); }else{ echo "<script>alert('賬戶或者密碼錯誤!重新填寫')</script>"; }