我正在建立一个网站来学习编码,我正在尝试构建一个Claim Your Business类型的应用程序。所以在claim.php上,我们搜索并列出所有业务,每个业务都有addclaimedbiz.php的链接?id = $ example_business_id 。然后在addclaimedbiz.php上我使用这段代码:
<?
$biz_id = mysql_real_escape_string($_GET['id']);
error_reporting(E_ALL);
$auth = $_COOKIE["auth"];
if ($auth != "1"){
header("Location: ./signin.php");
}
$firstname = $_COOKIE['firstname'];
$id = $_COOKIE['id'];
$fname = ucwords($_COOKIE['firstname']);
$lname = ucwords($_COOKIE['lastname']);
$email = $_COOKIE['email'];
$city = ucwords($_COOKIE['city']);
$biz = ucwords($_COOKIE['biz']); // This is Line 14
if (!empty($biz)){
header("Location: ./claim.php?alreadyclaimed=1");
}
else{
include("./config.php");
$result = mysql_query("INSERT INTO users (biz) VALUES ('$biz_id')") or die(mysql_error());
setcookie("biz", "", time()-3600); // This is Line 24
setcookie("biz", $biz_id, time()+60*60*24*30); // This is Line 25
header("Location: ./biz.php"); // This is Line 26
}
?>
基本上这是在抓取从claim.php传递给它的业务ID,(然后所有的cookie都是为了确保没有人未经授权进入该页面,但我不认为它与问题,但我把它保存在那里以防万一),然后它将id添加到表格中的 biz 字段,用户。然后在最后它重定向到biz.php。
不幸的是,当我运行此代码时,我得到错误:
Notice: Undefined index: biz in addclaimedbiz.php on line 14
Warning: Cannot modify header information - headers already sent by (output started at addclaimedbiz.php:14) in addclaimedbiz.php on line 24
Warning: Cannot modify header information - headers already sent by (output started at addclaimedbiz.php:14) in addclaimedbiz.php on line 25
Warning: Cannot modify header information - headers already sent by (output started at addclaimedbiz.php:14) in addclaimedbiz.php on line 26
它所说的行有错误的行号在上面的代码中。
我的代码出了什么问题?
感谢您的帮助!
答案 0 :(得分:1)
将第14行更改为:
$biz = $biz_id;