Mysql
 sql >> Database >  >> RDS >> Mysql

Come inviare persone a pagine diverse con mysql

Puoi recuperare i risultati e fare un'altra istruzione if all'interno del tuo rowCount() controlla

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';
    }
}