I’m building a website to learn coding, and am trying to build a Claim Your Business type of app. So on claim.php, we have a search and list out all the businesses, each with a link to addclaimedbiz.php?id=$example_business_id. Then on addclaimedbiz.php I use this code:
<?
$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
}
?>
Basically what this is doing is grabbing the business id that was passed to it from claim.php, (then all the cookies are to make sure no one unauthorized is getting to the page but I don’t think its that relevant to the problem, but I kept it in there in case it was), then its adding the id to the biz field in the table, users.Then at the very end it redirects to biz.php.
Unfortunately, when I run this code, I get the errors:
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
The line numbers for the lines it said had errors are in the code above.
What’s going wrong with my code?
Thanks for all help!
Change line 14 to this:
$biz = $biz_id;EDIT: SOrry, I never noticed that you are learning PHP.