您好我试图从我在PHP课程中编写的预处理语句中获取数据,而我尝试过Alot请在这里使用,这是类成员中的PHP函数
public function Check() {
$email = $this->getEmail();
$user = $this->getUsername();
$check = "SELECT firstName,lastName FROM members WHERE Email = ? AND Username = ? AND isActive = '1' ";
$stmt = $this->conn->prepare($check);
$stmt->bind_param("ss", $email, $user);
$stmt->execute();
return $stmt->fetch();
}
我想通过包含类并创建它的对象来获取另一个页面中的数据。这是我的尝试
<?php
$member = new Members();
$email = $member->setEmail(strip_tags(htmlspecialchars(trim($_GET['e']))));
$user = $member->setUsername(strip_tags(htmlspecialchars(trim($_GET['u']))));
if ($member->Check()) { echo $firstname." ".$lastname; } ?>
请帮忙.. 感谢
答案 0 :(得分:0)
$stmt->execute();
$stmt->bind_result($firstname, $lastname);
$stmt->fetch();
return array('firstname' => $firstname,'lastname' => $lastname);
$member = new Members();
$email = $member->setEmail(strip_tags(htmlspecialchars(trim($_GET['e']))));
$user = $member->setUsername(strip_tags(htmlspecialchars(trim($_GET['u']))));
$results = $member->Check();
if ($results) { echo $results['firstname']." ".$results['lastname']; } ?>