-1
I can’t seem to solve this problem :/,
Form file.php:
<?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 the $_SESSION
in the archive php form., when the user Submit, it stores the url in a $_SESSION
and redirects the user to the file x php., down at the archive x php. I try to display the $_SESSION
but without success.
Error message: Notice: Undefined variable: _SESSION
If I put session_start(); in the x.php file as well, the error message changes:
Esta página não está funcionando
MEUIP enviou uma resposta inválida.
ERR_INVALID_REDIRECT
session_start() is in x.php too?
– Felipe Duarte
no, when I put this message appears:
enviou uma resposta inválida.
ERR_INVALID_REDIRECT
– Nicolas Guilherme Matheus
Your.php form file is wrong, it has no opening or closing php tags and is mixed with html revise its syntax
– MagicHat
@Magichat was just an example is with the correct tags
<?php session_start(); ?>
– Nicolas Guilherme Matheus
So if you want help put with the correct syntax, still wrong.
– MagicHat
you have a php snippet inside the html form that does not have the php tags, review its syntax...
– MagicHat
@Magichat already edited, the code is with the tags.
– Nicolas Guilherme Matheus
At the top of the page
x
give avar_dump($_SESSION)
and glue the result– MagicHat
Result is
NULL
, without the<?php session_start(); ?>
on the pagex
, with the<?php session_start(); ?>
on the pagex
nothing appears butEsta página não está funcionando
MEUIP enviou uma resposta inválida.
ERR_INVALID_REDIRECT
– Nicolas Guilherme Matheus
Have some htaccess redirect?
– MagicHat
@Magichat I removed a function that makes the redirect and I was able to receive the value, but that’s exactly what I want to do, take the url and put this url in the header
– Nicolas Guilherme Matheus
Edit your question by placing exactly the code you have and detailing step by step what you want to do.
– MagicHat
@Magichat Editei
– Nicolas Guilherme Matheus