原始網頁http://www.php.cn/code/3984.html
#在第四步驟註冊處理頁面出現問題,註冊頁麵點立即註冊後調到註冊處理頁面報錯
#程式碼:
<?php
session_start();
//註冊處理介面regcheck.php
if(isset($_POST["hidden"]) && $_POST["hidden"] == "hidden")
{
$user = trim($_POST["username"]);//trim()函數移除字串兩側的空白字元## $_POST["userpwd"]));
$psw_confirm = md5(trim($_POST["confirm"]));
user == "" || $psw == "" || $psw_confirm == "")
{
(-1);</script>";
}
else if($code != $_SESSION, alert('驗證碼不正確,請重新輸入!'); history.go(-1);</script>";
} # if($psw = = $psw_confirm) {
# if(mysqli_errno($ conn)){
echo mysqli_error($conn);
}
mysqli_select_db($conn,"userdb"); f8 '); //設定字元集
#$sql = "select username from user where username = '$user'"; //SQL語句
$result = mysqli_query($conn,$0)) $num = mysqli_num_rows($ result); //統計執行結果影響的行數
if($num) //如果已經存在該用戶
{
echo "<script>alert('用戶名已存在'); history.go(-1);</script>";
}
{
$ip=ip2long($_SERVER[' REMOTE_ADDR']); // 將ip位址轉換為整數
$time=time();
username`,`userpwd`,`createtime`,` createip`) values('" . $user . "','" . $psw ."','".$time."','".$ip."')";
($conn,$sql_insert);
if($res_insert)
echo "<script>alert('註冊成功!');window.location.href='login.php'; </script>";
#}
echo "<script>alert('系統繁忙,請稍後嘗試!'); history.go(-1);</script>"; #
}
}
echo "<script>alert('密碼不一致!'); history.go(-1);</script>"; ##. ## }
}
}
!');</script>";
}
?>