$message[] = '请键入密码'; } if (empty($_POST['email'])) { $message[] = '请键入邮箱'; } if (empty($_POST['phone'])) { // 防止未提交 phone 字段导致出错 $_POST['phone'] = ''; } if (!count($message)) { // 如果不存在错误则查询数据库 $member = $db->get('member', array('id', 'name', 'email', 'phone', 'password', 'salt'), array('name' => $_POST['name'])); if (!$member) { $salt = rand(100000, 999999); $md5_password = md5($_POST['password'] . $salt); $member = $db->insert('member', array('name' => $_POST['username'], 'email' => htmlentities($_POST['email']), 'phone' => intval($_POST['phone']), 'password' => $md5_password, 'salt' => $salt, 'money' => 0)); if ($member) { $active = $db->insert('active', array('content' => '注册', 'username' => $_POST['username'], 'time' => date('Y-m-d H:i:s', time()))); header('Location: member.php?action=login'); unset($message); } else { $message = '无法完成注册,请重试'; } } else { $message[] = '该账号已被注册'; } } } } if (isset($message)) { $title = '账户';
/** * Log a pass attempt to the database * @param string $cardID the full card ID * @param boolean $access true if access was granted, false otherwise * @param string $username the username of the owner of the card, if known, defaults to null otherwise * @param string $reason the reason for the decision, if known, defaults to null otherwise * @return void */ public function logAttempt($cardID, $access, $username = null, $reason = null) { $this->medoo->insert('attempts', ['card_id' => $cardID, 'access_granted' => $access, 'username' => $username, 'reason' => $reason]); }