我不知道我的登錄腳本有什麼問題。它一直說無效的用戶名或密碼。但在我看來,一切都是按照原樣設定的。用戶登錄無效未知錯誤
PHP5:
<?php require ('../lib/config.php'); ?>
<?php
ob_start();
$tbl_name='users';
$user_name='Username';
$pass_name='Password';
$salt='';
mysql_connect("$cchost", "$ccuser", "$ccpass")or die("cannot connect");
mysql_select_db("$ccname")or die("cannot select DB");
$username=str_replace(' ','_', $myusername);
$myusername=$_POST['username'];
$mypassword=$_POST['password'];
$password=hash('whirlpool', $mypassword);
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$sql="SELECT * FROM $tbl_name WHERE $user_name='$username' and $pass_name='$password'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$donator=$row['donator'];
$player=$row['player'];
$count=mysql_num_rows($result);
if ($donator == '1') {
session_register("donator");
}
if ($player == '1') {
session_register("player");
}
if($count==1){
session_register("username");
header("Location: index_ucp.php");
}
else {
header("Location: login_ucp.php?err=1");
}
ob_end_flush();
?>
HTML表單:
<div class="login">
<form method="post" name="frmLogin" class="well form-inline" action="dologin.php">
<input name="username" type="text" class="input-medium" placeholder="Username">
<input name="password" type="password" class="input-medium" placeholder="Password">
<button name="btnLogin" type="submit" class="btn">Sign in</button>
</form>
</div>
我想了好幾個小時來修復它,但我不能。你們都是我最後的希望。 在此先感謝!
檢查值isset'isset($ _ POST [ 「username」])&&!empty($ _ POST [「username」]'和密碼相同 – karthikr
旁註:從['session_register()']手冊(http://www.php.net/manual/en/ function.session-register.php)**警告** 此功能自PHP 5.3.0起已經被取消,從PHP 5.4.0起移除。 - 在文件頂部添加錯誤報告 'error_reporting(E_ALL); ini_set('display_errors',1);' –
@karthikr我已經做到了,如果沒有,那麼有錯誤消息。現在正在測試.. - 沒有,它仍然說無效的用戶名和密碼。 –