本文整理汇总了PHP中DBObject::prepare方法的典型用法代码示例。如果您正苦于以下问题:PHP DBObject::prepare方法的具体用法?PHP DBObject::prepare怎么用?PHP DBObject::prepare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObject
的用法示例。
在下文中一共展示了DBObject::prepare方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DBObject
//DBObject included
require_once 'includes/Crypto.php';
require_once 'includes/constants.php';
if (!empty($_POST['username']) && !empty($_POST['userpass'])) {
$json = [];
$db = new DBObject(CURRENT_DB);
// $username = $db->escape($_POST['username']);
$username = $_POST['username'];
// $sql = "SELECT * FROM userinfo WHERE userpass = '$hashpass' AND username = '$username'";
$sql = "SELECT * FROM userinfo WHERE username = ?username:s";
$time = rand(1000 * 1000, 1000 * 500);
usleep($time);
// $query = $db->prepare($sql);
// error_log('query from login: ' . print_r($query, true));
// $query->bind_param('s', $username);
$db->prepare($sql);
$db->bind(array("username" => $username));
$json['status'] = 1;
$json['response'] = 'Invalid username/password!';
foreach ($db->execute() as $row) {
if ($db->getNumrows() > 1) {
$json['status'] = 3;
$json['response'] = 'Duplicate username detected! Please clean the database.';
die(json_encode($json));
}
if ($row['status']) {
$timestamp = Crypto::create_timestamp($row['regdate']);
$hashpass = Crypto::encrypt_password($_POST['userpass'], $timestamp[0]);
error_log($hashpass);
error_log($row['userpass']);
if ($hashpass === $row['userpass']) {