I had an issue with php. This code gave me error:
<input type="text" name="comment">
<tr>
<input type="submit" value="Post" name="Post">
<?php
if ($_POST['Post']) {
if (!isset($_COOKIE["c_user"])) {
die("Aby komentowac musisz byc zalogowany!");
} else {
$user = $_COOKIE["c_user"];
$comment = mysql_real_escape_string($_POST['comment']);
if ($_POST['comment'] && $_POST['$user']) {
mysql_query("INSERT INTO posts (comments, user) VALUES ('$user', '$comment')");
}
}
}
?>
Error looked like that:
Notice: Undefined index: Post in C:\xampp\htdocs\index.php on line 148.
I searched stackoverflow and followed answers. Then after upgrading the code to that version:
<?php
if (isset($_POST['Post'])) {
if ($_POST['comment']) {
if (!isset($_COOKIE["c_user"])) {
die("Aby komentowac musisz byc zalogowany!");
} else {
$user = $_COOKIE["c_user"];
$comment = mysql_real_escape_string($_POST['comment']);
if ($_POST['comment'] && $_POST['$user']) {
mysql_query("INSERT INTO posts (comments, user) VALUES ('$user', '$comment')");
}
}
} else {
echo "Komentarz nie został wpisany.";
}
} else {
echo "Post nie jest ustawiony!";
}
?>
It still doesn't read inner if statement and doesn't do cookie check. Please help.