我正在建立一个网站来学习编码,并正在尝试构建一个声明您的业务类型的应用程序。所以在 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字段users中。然后在最后它重定向到 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
它说有错误的行的行号在上面的代码中。
我的代码出了什么问题?
感谢大家的帮助!