session and history.go(-1) don't work

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ranpaco
Forum Newbie
Posts: 5
Joined: Sun Jun 05, 2005 3:02 pm

session and history.go(-1) don't work

Post by ranpaco »

help please
-----------------------pagina1.php-------------------------
<?php
session_start();
if ($_POST['Accion'] == "Insert"){
echo "<script language=\"JavaScript\">";
echo "window.location = \"pagina2.php\";";
echo "</script>";
}
?>
<html>
<head>
</head>
<body>
<form name="form1" method="post" action="pagina1.php">
<input name="Accion" type="hidden" value="Insert">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
-----------------------pagina2.php-------------------------
<?php
session_start();
?>
<html>
<head>
</head>
<body>
<a href="javascript:window.history.go(-1)">forward</a>
</body>
</html>


ok, firt load pagina1.php and click in submit button, that load
Pagina2.php, now when I click in link forward the explorer
end me a error of page not found, whyyyy?????


I realy need you help, thank a lot.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Re: session and history.go(-1) don't work

Post by Roja »

ranpaco wrote:ok, firt load pagina1.php and click in submit button, that load
Pagina2.php
No, your code doesn't.. it goes to pagina1.php:

Code: Select all

...
<form name="form1" method="post" action="pagina1.php">
...
ranpaco
Forum Newbie
Posts: 5
Joined: Sun Jun 05, 2005 3:02 pm

Post by ranpaco »

ok, see that:

if ($_POST['Accion'] == "Insert"){
echo "<script language=\"JavaScript\">";
echo "window.location = \"pagina2.php\";";
echo "</script>";
}

this lines redirect to pagina2.php

I know that this no have sense, but the original page has a lot more code that this.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

ranpaco wrote:ok, see that:

if ($_POST['Accion'] == "Insert"){
echo "<script language="JavaScript">";
echo "window.location = "pagina2.php";";
echo "</script>";
}

this lines redirect to pagina2.php

I know that this no have sense, but the original page has a lot more code that this.
Check and make sure that pagina1.php (after submit) is actually entering that code block.
ranpaco
Forum Newbie
Posts: 5
Joined: Sun Jun 05, 2005 3:02 pm

Post by ranpaco »

I'm really sure that pagina1.php after submit is entering to that code, because pagina2.php is load , the real problem is in pagina2.php when a try to return to pagina1.php doing a forward, when click in back page button on explorer or when call a javascript function window.history.go(-1).

thk a lot really
ranpaco
Forum Newbie
Posts: 5
Joined: Sun Jun 05, 2005 3:02 pm

Post by ranpaco »

hey, please I really need help, maybe is wrong the way I use the session_star() ??? I don't know!!! somebody pleasee :(
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

without the use of javascript...

Code: Select all

<?php
$url = "http://";
$url .= $_SERVER['HTTP_HOST'];
$url .= $_SERVER['REQUEST_URI'];
?>
ranpaco
Forum Newbie
Posts: 5
Joined: Sun Jun 05, 2005 3:02 pm

Post by ranpaco »

ok, problem solve
change the javascript for that:

Code: Select all

$url = &quote;http://&quote;;
$url .= $_SERVER&#1111;'HTTP_HOST'];
$url .= &quote;/&quote;.$_POST&#1111;'Accion'];
header('Location: '.$url);
thank for real help.
Post Reply