【问题标题】:header location not working on live but working in localhost标头位置不在现场工作,但在 localhost 工作
【发布时间】:2016-03-11 19:50:07
【问题描述】:
include "include/connection.php";
$date= date("Y-m-d H:i:s");
$profile_comment="INSERT INTO `infotown_test`.`profile_comments` (`id`, `user_id`, `name`, `email`, `comments`, `date_and_time`) VALUES (NULL, '".$_REQUEST['user_id']."', '".$_REQUEST['name']."', '".$_REQUEST['email']."', '".$_REQUEST['comment']."', '".$date."')";
mysql_query($profile_comment);
header("location:company-profile.php?id=2");(why it's not working?)

【问题讨论】:

  • 在该标题之前是否有任何 html 内容或回显?
  • 使用 $id = mysql_insert_id();我认为它因为 id 而不起作用
  • 在标头前检查查询错误。您应该在开发模式下开启错误报告。
  • header()函数之后尝试exit()
  • 危险:您使用的是an obsolete database API,应该使用modern replacement。您容易受到SQL injection attacks的影响,现代 API 可以让您更轻松地从 defend 中获得。

标签: php


【解决方案1】:

将“location”大写为“Location”,

header("Location:company-profile.php?id=2");

【讨论】:

    猜你喜欢
    • 2017-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-27
    • 2019-01-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多