真的wo'shi我試過很多方法,看過很多視頻,明明是一樣的代碼,為什麼我的都是不成功,別人的我不知道...很煩啊,未成功提示框也不顯示錯誤點在哪,感覺要崩潰了0_0
login.php:
#<!DOCTYPE>
<html>
#< ;head>
<meta charset="utf-8">
<title>登入</title>
<script>
'function init(){
# if(myform.username.value==""){
alert(" #");#
1 # /將遊標移到文字方塊中 myform.username.focus(); return false;myf value==""){ alert("請輸入密碼"); myform.userpwd.focus(); myform.userpwd.focus();### 問題 myform. # }###### if(myform.code.value==""){###### alert("請輸入驗證碼");###### myform.code.focus() ;###### return false;###### }###### }###### <cs/script>#.. ">###### .code{###### width: 80px;###### }#### ###### font-weight: bold;###### position: relative;###### left: 50px;### o #### background-color:#f0f0f0;###### width: 230px;###### }###1& ;##1/p; ######<body>######<form action="logincheck.php" method="post" name="myform">######<div>## #### <div>用戶登入</div>###### </div>###### <div>###### <span<div>###### gt; ;/span>###### <span><input type="text" name="username" id="username" placeholder="請輸入使用者名稱"></span>#### ### </div>
<div>
<span>密碼:</span>
<span><input type="text## <span><input type="text## <span><input type="text" name="userpwd><input type="text" name="userpwd><input type="text" name="userpwd><input type="text" name="userpwd> " id="userpwd" placeholder="請輸入密碼"></span>
</div>
<div>
o# # < ;驗證碼:</span> <span><input type="text" name="code" id="code" class ="code" placeholder= "請輸入驗證碼"></span> <!-- <span><img src="img.php" onclick="this.src='pic.php? nocache=' Math.random()" style="cursor:pointer"></span> --> <span><img src="img.php"><span><img src="img.php">< ;/span> </div> <div> <span><button>立即登入</button> ; <span><a href="register.php">註冊</a></span> </div><span><input type="hidden" value="hidden"></span>
#</form>
##< /body></html>regcheck.php<?phpheader("content-Type: text/html; charset=Utf-8");session_start();//註冊處理頁面regcheck.phpif (isset($_POST["hidden"]) &&$_POST["hidden"]=="hidden") { $user=trim($_POST["username"]);//使用trim函數移除字串兩側的空白字元 $pwd=md5(trim($_POST["userpwd"])); $pwd_confirm=md5(trim($_POST["confirm"])); $code=$_POST["code"]; if($user==""||$pwd==""||$pwd_confirm==""){ // echo "<script>alert("請確認訊息完整性"):history.go(-1);</script>"; }elseif ($code!=$_SESSION[ "var_code"]) { // echo "<script>alert("驗證碼不正確"):history.go(-1);</script>"; }else{ if ($pwd==$pwd_confirm) { $conn=mysql_connect("localhost","root","a123456");//連結資料庫的帳號密碼 if (mysqli_errno($conn)) { echo mysqli_errno($conn); exit; }# mysqli_select_db($conn,"userdb");//選擇資料庫 mysqli_set_charset($conn,"utf8");//設定字元集 // $sql="select username from USER where username='$user'";//sql語句 $sql = "SELECT * FROM `user` PROCEDURE ANALYSE()";# // mysql_query(query) $result=mysqli_query($conn,$sql);//執行SQL語句 $num = mysqli_num_rows($result); //統計執行結果影響的行數 if($num) //如果已經存在該使用者 { echo "<script>alert('使用者名稱已存在'); history .go(-1);</script>"; } else //不存在目前註冊使用者名稱 { $ ip=ip2long($_SERVER['REMOTE_ADDR']); // 把ip位址轉換成整數 $time=time(); $sql_insert = "insert into `user` (`username`,`userpwd`,`createtime`,`createip`) values('" . $user . "','" . $psw ."','".$time."','".$ ip."')"; //$sql = "SELECT * FROM `user` PROCEDURE ANALYSE()"; $res_insert = mysqli_query($conn,$sql_insert); if($res_insert) { echo "<script>alert('註冊成功! ');window.location.href='login.php';</script>"; } else # {echo "<script>alert('系統繁忙,請稍候!'); history.go(-1);</script>";
}
}
}
else
{
echo "<script>alert('密碼不一致!'); history.go(-1) ;</script>";
}
}
}
else
# {
# / / echo "<script>alert('提交未成功!');</script>";
echo "<script>alert('weichenggong');</script>";
}
?>
logincheck.php
<?php
header("content-Type: text/ html; charset=Utf-8");
session_start();
//登入處理介面logincheck.php
//判斷是否按下提交按鈕
if(isset($_POST["hidden"]) && $_POST["hidden"] == "hidden")
{
//將使用者名稱和密碼儲存入變數中,供後續使用
$user = trim($_POST["username"]);//trim()函數移除字串兩側的空白字元
$psw = md5(trim($_POST["userpwd"]));//密碼使用md5()加密一次,存入資料庫
$code = $_POST["code"];
if($user == "" || $psw == "")
{
//使用者名稱或密碼其中一個為空,則彈出對話框,確定後返回目前頁面的上一頁
echo "<script>alert('請輸入使用者名稱或密碼!'); history.go(-1);</script>";
# }else if($code != $_SESSION[' ver_code']){
echo "<script>alert('驗證碼不正確,請重新輸入! '); history.go(-1);</script>";
}
else
{ //確認使用者名稱密碼驗證碼不為空,則連接資料庫
$conn = mysqli_connect("localhost","root","a123456");//資料庫帳號密碼為安裝資料庫時設定
if(mysqli_errno($conn )){
echo mysqli_errno($conn);
exit;
}
mysqli_select_db($conn,"userdb");
# mysqli_set_charset($conn,'utf8');
# $sql = "select username,userpwd from user where username = '$user' and userpwd = '$psw'";
# //$sql = "SELECT * FROM `user` PROCEDURE ANALYSE()";
$result = mysqli_query($conn,$sql);
$num = mysqli_num_rows($result );
if($num)
{
echo "<script>alert('成功登入'); window.location.href='index.php ';</script>";
}
# else
{
echo "<script>alert('使用者名稱或密碼不正確!');history.go(-1);</script>";
}
# }
}
else
# {
echo "<script>alert('提交未成功!');</script>" ;
}
?>
register.php
<!DOCTYPE html>
# <html>
<head>
<title>php.cn</title>
<meta charset="utf-8" />
<style>
.box{
width:250px;
height:120px;
background:#f0f0f0;
}
</style>
</head>
<body>
# <!--註冊界面register.php-->
<div class="box" align="center">
<div>用戶註冊</div>
<form action="regcheck.php" method="post">
<table>
<tr>
# <td align ="right">使用者名稱:</td>
<td><input type="text" name="username" maxLength="6"/></td>
</tr>
<tr>
# <td align="right">密碼:</td>
<td><input type="password" name="userpwd" maxLength="6"/></td>
</tr>
<tr>
</tr>
<tr> ;
<td align="right">確認密碼:</td>
<td><input type="password" name="confirm" maxLength= "6"/></td>
</tr>
<tr>
<td colspa="2" align="right "><input type="Submit" name="Submit" value="註冊"/></td>
</tr>
</table> ;
</form>
</div>
</body>
###</html>###### #求大神解決,我覺得再解決不出來,我的頭髮都要掉光了###