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

PHP ??? ?? ??

?? ????? ?? ???? ???? reg.php? ???????

2.png

regin.php ??? ??? ?????

?? ??? ???????

  1. ? ????? ??????

  2. ?? ?? ????

  3. ??? ?? ??? ?????

  4. SQL ?? ???? ??????? ???? ?????

  5. ?? ?? ??? ?????

?? : ??? ???? ? ?? ? ?? ?????. ??? ?? ??? ??? ??????? ???? ??, ??? ??? Zhang San? ?? ??? ???? ??? ????? ? ???. ??? ?? Zhang San? ???? ?? ?? ??? ??? ?? ???? ??? ???? ???.

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

regs.png

??? ?????. ??????? ?? ???? ?????. ?? ??? ???? conn.php ??? ?????

, ?? ??? ?? ?? ??? ??? ??? ? ????. Trim() ??? ???? ????? ??????. ??? ??:

$name=trim($_POST['username']);

$ ????=$_POST['password'];

trim ??, ?? ??, ??? ?? ?? ?? ?? ?????. ??? ?? ?? ??? ??? ??? ???? Firebug ??? ??? ?? ??? ??? ?? ?? ??? ?? ??? ? ? ????. ??, ??? ??? ???? ???? ??? ???? ? ????

??? ?? ?? ?? ??

9.pngtrim() ??? ???? ?? ??? ?? ??? ?? ?? ?? ??? ? ???,

10.png?? ? ??? ??? ????

11.pngmd5( ) ???? ?? ? 32?? ???? ?????

12.png??? ?? Zhang San, ?? 123456, ????? ?????

13.png??? ???? ?????. ??? ????. ?? ??? ??? ?? role

?? ??? ??? ?????? ???? ???


?? ?? ??? ??? ?? ?????? ???? ?? ??? ??? ?????

??? ??? ????

$sql = "select * from user where username='$name'";
$info = mysql_query($sql);
$res = mysql_num_rows($info);

?? ?? $res? ?????. ???? ?? ???? ?????? ???? ???? ?? ???? ?????

??? ?? ?? ?? ??? ?????

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

??? ??? ????:

if(empty($name)){
?????????????echo "<script>alert('??? ??? ??? ? ????');location.href= 'reg.php';</script>" ;
}else if(empty($password)){
?echo "<script>alert('????? ??? ? ????.');location.href='reg.php ';</script>";
}else {

//?? ??

}

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

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? { ')";
$result = mysql_query($sql1);
if($result){
"alert('?? ??')</script>";
}else {
???????????????echo "< ;script>alert('?? ??')</script>";
???}

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

<?php
    require_once("conn.php");//首先鏈接數(shù)據(jù)庫
    $name=trim($_POST['username']);
    //trim函數(shù),過濾空格,如果不加,我們在用戶名后面添加很多空格,提交表單,打開firebug
    //調(diào)試工具,我們可以到輸入的用戶名后面會有很多空格,使用trim函數(shù),我們可以把表單中空格給過濾掉
    $password=$_POST['password'];

       $sql = "select * from user where username='$name'";
        $info = mysql_query($sql);
        $res = mysql_num_rows($info);

    if(empty($name)){
        echo "<script>alert('用戶名不能為空');location.href='reg.php';</script>";
    }else if(empty($password)){
        echo "<script>alert('密碼不能為空');location.href='reg.php';</script>";
    }else{    
        if($res){
            echo "<script>alert('用戶名已存在');location.href='reg.php';</script>";
        }else{
            $sql1 ="insert into user(username,password) values('".$name."','" .md5($password)."')";
            $result = mysql_query($sql1);
            if($result){
                     echo "<script>alert('注冊成功')</script>";
            }else{
                     echo "<script>alert('注冊失敗')</script>";
            }
        }
}    
?>

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

???? ??
||
<?php require_once("conn.php");//首先鏈接數(shù)據(jù)庫 $name=trim($_POST['username']); //trim函數(shù),過濾空格,如果不加,我們在用戶名后面添加很多空格,提交表單,打開firebug //調(diào)試工具,我們可以到輸入的用戶名后面會有很多空格,使用trim函數(shù),我們可以把表單中空格給過濾掉 $password=$_POST['password']; $sql = "select * from user where username='$name'"; $info = mysql_query($sql); $res = mysql_num_rows($info); if(empty($name)){ echo "<script>alert('用戶名不能為空');location.href='reg.php';</script>"; }else if(empty($password)){ echo "<script>alert('密碼不能為空');location.href='reg.php';</script>"; }else{ if($res){ echo "<script>alert('用戶名已存在');location.href='reg.php';</script>"; }else{ $sql1 ="insert into user(username,password) values('".$name."','" .md5($password)."')"; $result = mysql_query($sql1); if($result){ echo "<script>alert('注冊成功')</script>"; }else{ echo "<script>alert('注冊失敗')</script>"; } } } ?>