-1

Hello everyone is there any way to redirect page without header() and java script ? is php has another function that can redirect page ?

first page ...

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

second 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'> ordered </a>";

third page... wher my second page come here when i click on ordered link

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

//header('location:items.php?item=$itemid');----> here i am getting error

Unknown column '$item' in 'where clause' i get this error when i click on ordered link.

Yeldar Kurmangaliyev
  • 33,467
  • 12
  • 59
  • 101
  • why not use header()? it is perfect for the job – Professor Abronsius Apr 27 '15 at 12:51
  • 2
    Why don't you want to use the right tools for the job? – John Conde Apr 27 '15 at 12:51
  • Why PHP should have another tool to do the same as header?? – Lelio Faieta Apr 27 '15 at 12:53
  • 1
    beacuse header() is giving me error. it isnt working with $_Get variable –  Apr 27 '15 at 12:53
  • please share your header() code, maybe we can figure out what the problem is. – tanaydin Apr 27 '15 at 12:55
  • $productid=$_GET['product']; $my_id=$_SESSION['user_id']; if($action=='send'){ mysql_query("INSERT INTO item VALUES ('','$my_id','$productid')"); } $url="profile.php?user=$productid"; echo "";//here i used js but somone has disabled his js from his browser and this page wont redirect. //header('location:profile.php?user=$productid'); –  Apr 27 '15 at 13:06

3 Answers3

4

you can use meta refresh tag. no php, no javascript needed. syntax like so..

<META http-equiv="refresh" content="10;URL=http://www.google.com/">

10 is seconds, URL is page to redirect.

tanaydin
  • 5,171
  • 28
  • 45
3

You can use header().

Example:

header("Location: /newpage.php");

Also you can use meta:

<META http-equiv="refresh" content="0;URL=http://www.yoursite.com/">
1

there is a meta tag that you can redirect, but you should use header(),

<META HTTP-EQUIV="Refresh" Content="0; URL=page.php">

Mete Kabak
  • 332
  • 3
  • 19