I can not solve this problem: /,
Form.php file:
<?php session_start(); ?>
<form action="x.php" method="post">
<?php
$_SESSION["urlName"] = $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"];
echo $_SESSION["urlName"]; // o valor é exibido aqui no formulario.php.
?>
<input type="email">
<button type="submit"></button>
</form>
x.php file:
<?php
require("redirect.php");
$urlName = $_SESSION["urlName"]; //o valor não chega aqui no x.php, Pq?
if(isset($_SESSION["urlName"]))
echo $urlName;
else
echo "URL NÃO encontrada";
pageRedirect($urlName);
File redirect.php:
function pageRedirect($urlName){
header("Location: " . $urlName);
die();
}
Summarizing the code:
I open $_SESSION
in the form.php file, when the user submit , it stores the url in a $_SESSION
and redirects the user to the x.php file, there in the x.php file I try to display the $_SESSION
stored, but to no avail.
Error message: Notice: Undefined variable: _SESSION
If I put session_start (); in the x.php file too, the error message changes:
Esta página não está funcionando
MEUIP enviou uma resposta inválida.
ERR_INVALID_REDIRECT