0

私はコーディングを学ぶためのウェブサイトを構築しており、ClaimYourBusinessタイプのアプリを構築しようとしています。したがって、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は、許可されていない人がページにアクセスしないようにするためのものですが、問題に関連しているとは思いませんが、しかし、万が一の場合に備えて、そこに保持しました)、次に、テーブルのbizフィールドにIDを追加します。その後、最後に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

エラーが発生したと述べた行の行番号は、上記のコードにあります。

私のコードの何が問題になっていますか?

すべての助けをありがとう!

4

1 に答える 1

1

14行目を次のように変更します。 $biz = $biz_id;

編集:申し訳ありませんが、PHPを学習していることに気づきませんでした。

于 2012-08-06T23:00:56.127 に答える