I have set cookie up in my code, but when I try to fetch the cookie value I get following error:
Notice: Undefined index: mailquery in D:\Dev\htdocs\index.php on line 24
I have no idea what to do here. This is on a blank website, using newest version of XAMPP.
What is going wrong?
My code:
<?php
include "sqlconnect.php";
$connect = mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_query("CREATE DATABASE IF NOT EXISTS users;") or die(mysql_error());
mysql_query("USE users;") or die(mysql_error());
mysql_query("CREATE TABLE IF NOT EXISTS userinfo(id int AUTO_INCREMENT NOT NULL,
mail varchar(255) default 0 NOT NULL,
phone varchar(10) default 0 NOT NULL,
PRIMARY KEY(id));") or die(mysql_error());
if($_REQUEST['extr'] == 0){
mysql_query("INSERT INTO userinfo(mail, phone) VALUES(" . "'". $_REQUEST['x'] . "'" . ", " . $_REQUEST['y'] . ");") or die(mysql_error());
};
if($_REQUEST['extr'] == 1){
$query = mysql_query("SELECT * FROM userinfo;");
$result = mysql_fetch_row($query);
setcookie("mailquery", $result[1] . $result[2], time() + 300, "/");
};
echo $_REQUEST['mailquery'];
?>