duanjinchi1982 2016-07-19 10:38
浏览 36
已采纳

使用godaddy如何使用标题(“位置:URL”)

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

  • 写回答

2条回答 默认 最新

  • dongyudun6465 2016-07-19 10:55
    关注

    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.
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度