0

I have controllerLoginUsu.php :

<?php

require "dao/daoLoginUsu.php";  

class LoginUsuario{

    public function setDatos($aInput) {

        $obj = json_decode($aInput, true);

       $Dao = new daoLoginUsuario();
       $Dao->setDataDato($obj);

       $msj = $Dao->setDataDato($obj);


      session_start();
      if ($msj === 'si') {
          $_SESSION['msj'] = "si";
          return $msj;
          header("http://localhost:8080/formulario_web/formulario/formulario_lazos.php");
          exit; 

      }
   } 
}
?>

After I start session and return $msj I need redirect but with header don't work. some other solution to this case?

Sorry my english.

2

4 Answers 4

1

You forgot the Location.

try:

header("Location: http://localhost:8080/formulario_web/formulario/formulario_lazos.php");
Sign up to request clarification or add additional context in comments.

Comments

1

You never ever reach the header() call:

 return $msj;  // terminate function IMMEDIATELY
 header("http://localhost:8080/formulario_web/formulario/formulario_lazos.php"); // never reached

return should come AFTER header().

Comments

1

If you want to redirect without header, try this:

echo "<script>";
echo "location.replace('classes.php?add=sucess')";
echo "</script>";

1 Comment

This is actually a very nasty way of doing the same thing as a header() as the whole page gets built->sent to the browser->then the DOM is built by the browser->AND THEN EVERYTHING IS THROWN WAY. very wasteful
0

The answer is actually a mixture of 2 of the below

If you are issuing a header() you dont want to return anything as you are forcing the loading of a new form. The return will of course stop execution of this method and in your case the header will then not even get executed.

Also you forgot to add the location: part of the header() statement.

So

if ($msj === 'si') {
    $_SESSION['msj'] = "si";
    header("Location: http://localhost:8080/formulario_web/formulario/formulario_lazos.php");
    exit; 
  }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.