Reputation: 1746
Desired flow
www.example.com
(list of all persons)www.example.com?view-person=1
(view details of person 1) www.example.com?edit-person=1
(editing form for person1)?view-person=1
Form action in ?edit-person
is action="www.example.com"
.
Inside www.example.com
is the following snippet
if(isset($_POST['edit-person']))
{
// record edit
header("location:javascript://history.go(-1)"); // supposed to go back to ?view-person but just returns to ?edit-person
}
I've tried
header("location:javascript://history.go(-1)");
And
header("location:javascript://history.go(-2)");
But it just sends me back to ?edit-person=1
instead of ?view-person=1
.
I can't also just do header("location:www.example.com?view-person='$id'");
because it sends me to www.example.com?view-person=%272%27
I dont know if what I'm planning is possible or not.
Upvotes: 0
Views: 166
Reputation: 111
You're using GET Method and validating by POST, use $_REQUEST instead.
i've tried this code and it works fine.
<?php
if(isset($_REQUEST['edit-person']))
{
echo "<script>history.go(-2);</script>";
}
?>
Upvotes: 1
Reputation: 97565
Do javascript:
urls even work in the Location
header? You're not doing PHP string interpolation correctly - you want:
header("location:www.example.com?view-person=$id");
Upvotes: 0