結果をフェッチして、rowCount()
内で別のifステートメントを実行できます。 チェック
public function Login($name, $pass){
if(!empty($name) && !empty($pass)) {
$st = $this->db->prepare("select * from users where username=? and password=?");
$st->bindParam(1,$name);
$st->bindParam(2,$pass);
$st->execute();
$results = $st->fetchObject();
if($st->rowCount() == 1) {
if ($results->colName == "agent") { // Change colName to any column that contains the agent and notagent value
header("Location: account1.php");
} else {
header("Location: account2.php");
}
} else {
echo 'Incorrect username or password.';
}
} else {
echo 'Please enter username and password';
}
}