0

Hi everyone,

Is there any way to redirect page without header and javascript ?

Edited by phoenix254

3
Contributors
7
Replies
25
Views
2 Years
Discussion Span
Last Post by phoenix254
1

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.

Edited by gentlemedia

0

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>";
    }
?>
0

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>";

Edited by phoenix254

0
$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');

Edited by phoenix254

0

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");
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.