Reputation: 317
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.
Upvotes: 0
Views: 120
Reputation: 185
If you want to redirect without header, try this:
echo "<script>";
echo "location.replace('classes.php?add=sucess')";
echo "</script>";
Upvotes: 1
Reputation: 94652
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;
}
Upvotes: 0
Reputation: 360602
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()
.
Upvotes: 1
Reputation: 2408
You forgot the Location.
try:
header("Location: http://localhost:8080/formulario_web/formulario/formulario_lazos.php");
Upvotes: 1