try and catch with redirect to another page

0

Colleagues.

I have the following code:

try{
  if($param['usuario'] != '' and $param['senha'] != ''){
    return "<script>window.location.href='painel.php';</script>";
  }else{
    throw new Exception('Erro ao acessar');
  }
}catch(Exception $e){
   $erro = $e->getMessage();
}

I want to put it this way, but I do not know if it's the right one:

throw new Exception('<script>window.location.href='erro.php';</script>');

I always use messages, but I would like to point to another page. I'm unsure how to use the form I passed, using Exception targeting. Is there another way using try and catch or can I use it that way?

    
asked by anonymous 05.07.2016 / 14:27

0 answers