Tuesday, 1 May 2018
mysql - PHP isn't processing some form fields
Answer
Answer
I recently created a PHP/MySQL comment system, and it was working until a few hours ago (no changes at all in the code). When I tell the submit form code to echo the query, it shows that the area for commenttext and date is missing. I don't see why. Here's my code:
mysql_connect("localhost","commentUser","password");
mysql_select_db("comments");
$name = mysql_real_escape_string($_POST['name']);
$postID = mysql_real_escape_string($_POST['postId']);
if(!is_numeric($postID))
exit();
$email = mysql_real_escape_string($_POST['email']);
$comment = strip_tags(mysql_real_escape_string($_POST['comment']), '');
$date = mysql_real_escape_string($_POST['date']);
if($email == '' || $comment = '' || $date = '')
exit();
$query = "INSERT INTO comments (PostID,Name,Email,Text,Date) VALUES($postID, '$name', '$email', '$comment', '$date')";
mysql_query($query) or die(mysql_error());
mysql_close();
echo "
window.location = \"snippet.php?id=$postID\";
";
Answer
You are assigning the empty string to $comment
and $date
with =
if($email == '' || $comment = '' || $date = '')
exit();
// Should use `==` for all three:
if($email == '' || $comment == '' || $date == '')
exit();
Subscribe to:
Post Comments (Atom)
casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV
In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...
-
The whole error output being: LNK2019 unresolved external symbol wWinMain referenced in function "int __cdecl __scrt_common_main_seh(vo...
-
I have come across CORS issues multiple times and can usually fix it but I want to really understand by seeing this from a MEAN stack paradi...
-
I recently used canvas to conert images to webp, using : const dataUrl = canvas.toDataURL('image/webp'); But this takes a lots of ti...
No comments:
Post a Comment