我似乎有一個登錄腳本的問題,它工作在本地的PHP開發盒,但不是在我的生活環境,我假設我失去了一些人可以任何人進一步建議?登錄腳本本地工作,但不在現場環境
<?php
$user = $_POST["swtorun"];
$pass = $_POST["swtorpw"];
// Generate hash
$enc_pwd = hash('sha256', $pass);
// Connect to DataBase
include('../../settings.php');
$conn = mysql_connect($host,$username,$password);
$db = mysql_select_db($database, $conn);
// mySql Query users
$sql = "SELECT * FROM `users` WHERE username='$user' and password='$enc_pwd'";
$result = mysql_query($sql, $conn);
$count = mysql_num_rows($result); // number of results (should be 1)
if($count==1){
// initiate session
session_start();
$_SESSION['logged'] = "1";
echo "you are now logged in, return to the <a href=\"../../index.php\">index</a>";
} else {
echo "Wrong Username or Password";
}
?>
請定義「不起作用」。有沒有錯誤? – Connum 2012-01-13 17:02:27
在開箱上它工作正常,在生活我得到我的「錯誤的用戶名和密碼」輸出。 – 2012-01-13 17:03:20
=> http://xkcd.com/327/:請使用'mysql_real_escape_string()'! – ComFreek 2012-01-13 17:04:02