Web で見つけたログイン スクリプトを使用しています。( http://alias.io/2010/01/store-passwords-safely-with-php-and-mysql/ )
機能させようとしていたときに、次のエラーに遭遇しました。
bool(false) 致命的なエラー: 行 25 の /srv/disk3/1446018/www/askmephilosophy.co.nf/session.php の非オブジェクトに対するメンバー関数 bindParam() の呼び出し
私のコード:
<?php
include('config.php');
// Establishing the connection:
$MyConnection = mysqli_connect('hostname', 'user', 'pass', 'database')
or die('An error has occured when you were trying to login. You can return to the main page
by clicking: <a href="index.php">here</a>. <br />
If this error is consistent, please <a href="contact.php">contact us</a>.');
// Information provide by the user:
$username = $_POST['username'];
$password = $_POST['password']; // Text version.
$StatementHandle = $MyConnection->prepare('
SELECT
hash
FROM Users
WHERE
username = :username
LIMIT 1
');
var_dump($StatementHandle);
$StatementHandle->bindParam(':username', $username);
$StatementHandle->execute();
$user = $StatementHandle->fetch(PDO::FETCH_OBJ);
// Hashing the password with its hash as the salt returns the same hash:
if(crypt($password, $user->hash) == $user->hash) {
echo 'You are logged in. Well, not actually. We only just confirmed that
our system works. This service\'ll cost you $1';
}
?>