Question

How can I write the php locate variable code when redirect to right page! I have pagination and if I'm in second or 3rd page, and then process sending data to database using ajax like this code

<script type="text/javascript">

$.ajax({
type: "GET",
url: "action.php",
data: { status: "<?php echo $_GET['pid'];?>" }
})

</script>

and then redirect back to pagination.... I want to redirect back to page 2nd or 3rd page instead of first page.

I copied second page of pagination url address and I pasted into php location code is works great see the code...

header("Location: http://shopone/admin45/pagination/davetwo.php?cat=&rows=10&page=2");

See the code where it said ?cat=&rows10 mean number of row per page.

See &page=2 mean page 2

In local variable I know this is not right code but need help

header("Location: http://shopone/admin45/pagination/davetwo.php".($_GET['page'] ? '?page='.$_GET['page']:''));

How can i write the variable code to put variable for cat and page! to redirect into right page where left from pagination page!

Was it helpful?

Solution

I think I know what you're asking. Here is a snippet that will produce the complete URL for the current PHP script, including the query string:

$full_url = ($_SERVER['HTTPS'] == "on" ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
echo $full_url;

And if you just want the query string on the end, i.e. cat=&rows=10&page=2, you can use:

echo $_SERVER['QUERY_STRING'];

So I believe in your case what you're looking for is something like this:

$full_url = ($_SERVER['HTTPS'] == "on" ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header("Location: ".$full_url);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top