0
我已經創建了兩個表名爲登錄和gotest.in gotest表我已經存儲了用戶的詳細信息和獨特的表中ID.in登錄表我存儲refid,用戶名和password.refid是主鍵在gotest table中包含相同的ID值。當它通過URl時,我從一個表單獲得ID。但當iam嘗試登錄時,它給我這個errpor「用戶名或密碼不正確!」。Php Mysql登錄
這裏是我的PHP代碼我的登錄頁面
<?php
include_once 'dbconnect.php';
$renewid = $_GET['ID'];
$query = "SELECT refid, username, password FROM ipay_login WHERE refid = '$renewid'";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$renewid = $row['refid'];
$uname = $row['username'];
$upass = $row['password'];
echo $renewid . '<br />';
echo $uname . '<br />';
echo $upass . '<br />';
}
if(isset($_POST['btn-signup'])) {
$uname = $_POST['username'];
$upass = $_POST['password'];
/*echo $uname,$upass,$renewid;*/
$result1 = mysql_query("SELECT * FROM ipay_login WHERE username = '$uname' AND password = '$upass'");
if(mysql_num_rows($result1) > 0)
{
echo "sucesss";
}
else
{
echo 'The Username or password are incorrect!';
}
}
?>
<html>
<head></head>
<body>
<form id="convertion" method="post">
<!--<input type="hidden" id="refid" name="refid" value="<?php /*$_GET['refid']; */?>" /><br/>-->
<input type="text" id="username" name="username" /><br/>
<input type="text" id="password" name="password" /><br/>
<button type="submit" id="btn-signup" name="btn-signup">SUBMIT</button>
</form>
</body>
</html>
URL
http://xxx.yyy.example?ID=1000
如果用戶名和密碼都存儲在'ipay_login'表中,那麼爲什麼在SELECT查詢中使用'gotest'表? –
你爲什麼認爲它應該輸出不同的東西? –
請注意,'mysql_ *'函數在PHP 5.5中被棄用,並且在PHP 7.0中被完全刪除。使用['mysqli'](http://php.net/manual/en/book.mysqli.php)或['pdo'](http://php.net/manual/en/book.pdo.php)代替。 [這就是爲什麼你不應該使用'mysql_ *'函數](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php)。 –