Hi everyone,
Is there any way to redirect page without header and javascript ?
Via a .htaccess file:Redirect 301 /oldpage.html http://www.example.com/newpage.html
I've used 301 in this example. but this can also be 302. The difference is that a 301 redirect means that the page has moved to a new location, permanently. A 302 redirect means that the move is temporary.
i have 3 page
first page(x) redirect me to second page(y) and when i do some action from second page and my third page i called actions.php and that action i did from page y it go to actions.php. From action php should automatocally redirct to my second page (y).
page x o first page is like this ...
<?php
$item_query=mysql_query("SELECT * FROM items ") or die(mysql_error());
while($run_item=mysql_fetch_array($item_query))
{
$itemid=$run_item['item_id'];
$name=$run_item['productname'];
echo "<br/>";
echo "<a href='product.php?product=$userid'>$username</a>";
}
?>
this is my 2° page...
if(isset($_GET['product'] ) && !empty($_GET['product'])){
$itemid=$_GET['product'];
}else{
$itemid= $_SESSION['item_id'];
}
$Item_query=mysql_query("SELECT * FROM item WHERE item_id=$itemid") or die( mysql_error());
while($run_item= mysql_fetch_array($mem_query)){
$meid=$run_item['item_id'];
$name=$run_item['name'];
}
$my_id=$_SESSION['item_id'];
echo '<h3> Your Name: '.$name."<br/>ID: ".$meid.'</h3>';
$sendquery=mysql_query("SELECT fid FROM order WHERE inorder= $itemid AND userid= $my_id ")or die (mysql_error());
echo "<a href='actions.php?action=send&product=$itemid'> Send Reqeust </a>";
$action=$_GET['action'];
$itemid=$_GET['item'];
$my_id=$_SESSION['item_id'];
if($action=='send'){
mysql_query("INSERT INTO order VALUES ('','$my_id','$userid')");
}
header('location:items.php?item=$itemid');
My PHP skills are very limited, so you'll have to wait for someone else to jump in :)
Hi,
in this case you can use header()
, you could setup actions.php like an hub and define specific redirect links:
switch($_GET['action']):
{
case 'send':
# run insert query
$redirectTo = "http://website.tld/pageY.php";
break;
case 'update':
# run code here
$redirectTo = "http://website.tld/pageX.php";
break;
default:
$redirectTo = "http://website.tld/pageA.php";
}
header("Location: $redirectTo");
Also when using single quotes, PHP will not parse the variable, so:
header('location:items.php?item=$itemid');
Will literally output items.php?item=$itemid
, not items.php?item=17
as expected. You have to use double quotes:
header("Location: http://website.tld/items.php?item=$itemid");
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.