1
The problem is this:
Form file.php:
<?php session_start(); ?>
<form action="x.php" method="post">
<?php
$_SESSION["urlName"] = $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"];
echo $_SESSION["urlName"];
?>
<input type="email">
<button type="submit"></button>
</form>
x.php file:
<?php
require("redirect.php");
$urlName = $_SESSION["urlName"];
if(isset($_SESSION["urlName"]))
echo $urlName;
else
echo "URL NÃO encontrada";
pageRedirect($urlName);
File redirect.php:
<?php
function pageRedirect($urlName){
header("Location: " . $urlName);
die();
}
Value received on $urlName
:
"192.168.x. xx:xxx/project/site-x/index.php"
Type: String
ERROR MESSAGE:
This page is not working 192.168.x. xx sent an invalid reply. ERR_INVALID_REDIRECT
*
OBS: Is not duplicate of Undefined variable: _SESSION, are different issues.
Hosts file:
# copyright (c) 1993-2009 microsoft corp.
#
# this is a sample hosts file used by microsoft tcp/ip for windows.
#
# this file contains the mappings of ip addresses to host names. each
# entry should be kept on an individual line. the ip address should
# be placed in the first column followed by the corresponding host name.
# the ip address and the host name should be separated by at least one
# space.
#
# additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# for example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within dns itself.
# 127.0.0.1 localhost
# ::1 localhost
@Fernando that post was on the subject of Session, this is about the redirect error, the staff of the other post who advised me to create a new topic with this new problem
– Nicolas Guilherme Matheus
You have access to apache files, what your operating system is?
– MagicHat
@Magichat SO: Windows, I think so.
– Nicolas Guilherme Matheus
How are you
C:/WINDOWS/system32/drivers/etc/hosts
?– MagicHat
@Magichat edited the topic, put the content of hosts in it.
– Nicolas Guilherme Matheus
Uncomment the line of
localhost
.– MagicHat
127.0.0.1 localhost
and restart the apache.– MagicHat
@Magichat solved some things, now the problem is another :s, it redirects, however it does not erase the url that was before, it just complements it. example: it goes to the url:
localhost/projetos/site/x.php
, and when you run the function, this is the urllocalhost/projetos/site/x.php/localhost/index.php
, and the goal is just to redirect tolocalhost/index.php
– Nicolas Guilherme Matheus
@Magichat ARRUMEEEEEEEEI Finally kkkkk, our, how bad it is not to know how to do things kkkk, thanks for the help Magic, it was no problem in apache no, there were 2 errors, 1 was that there was session_start in the form.php(yes I had put, I must have erased to test and I ended up not returning him), and the other error dps to have fixed this, was that in
header("Location: " . $urlName);
, had to put thehttp://
header("Location: http://" . $urlName);
– Nicolas Guilherme Matheus