0

On my localhost this page redirection working properly but when I setup my project on Godaddy hosting site it doesn't redirect to page it actually displaying same page! My code is as below:

<?
session_start();
include_once('connection.php');

$news_id=$_GET["id"];
$m_id=$_GET["m_id"];
$category =$_GET["category"];

$res=mysqli_query($con,"delete from marathi where id=$news_id");
if($res<=0)
{
    $_SESSION["MSG"]="News not deleted, Try Again";
    header("Location: m_news.php?id=".$m_id."&name=".$category);    
}
else
{
    $_SESSION["MSG"]="News deleted";
    header("Location: m_news.php?id=".$m_id."&name=".$category);    
}
?> 

When I use godaddy this line is not working ..

header("Location: m_news.php?id=".$m_id."&name=".$category);

FirstOne
  • 6,033
  • 7
  • 26
  • 45
Abhijit Kumbhar
  • 923
  • 3
  • 23
  • 49

2 Answers2

1

Always add a die() call after issuing Location headers.

The HTTP response must be terminated without any body data for browsers to properly interpret the redirect headers, if you just run your header() and let the PHP script continue there is no guarantee that the body of the response will be empty and if it isn't the redirect will not work.

header("Location: m_news.php?id=".$m_id."&name=".$category);
die(); // Stop further execution and prevent any accidental output.
kb.
  • 1,955
  • 16
  • 22
0

This is good practice to add die(); after every redirect. This stops execution of next script.

 header("Location: m_news.php?id=".$m_id."&name=".$category);
 die();
Deepak Dholiyan
  • 1,774
  • 1
  • 20
  • 35