Redirect page with error message

3

Good afternoon, I have a question Is this command correct?

http://localhost/site/index.php#contato?info=Email%20Vazio

  

index.php # contact? info = Email% 20Value

This is the function that sends the command but the page is at the top and the message no longer appears on the form.

private function setNome($nome){
    if(!empty($nome)){
    $validar = new Validar($nome);
    $this->nome = $validar->getValidado();
    }else{
    $this->setError("Nome Vazio");
    return print "<script language='JavaScript'>location.href='"
    . "index.php#contato?info={$this->getError()}'</script>";
    exit();
    }

If I remove the #contato , it works but I'd like it to go straight to the form so that the user does not have to scroll down the page again at every typo

    
asked by anonymous 01.11.2017 / 20:15

1 answer

0

Adriano! uses the header () function of php, with which you do this redirect.

Ex:

Header (location: 'www.google.com');

    
01.11.2017 / 20:20