Why not add an entry in the guest book?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
9 views
When you add a name and comment into the form POPs up the message 'an Error occurred while adding entries to the guest book', created in guestbook.php and connected via separate file alert.php guestbook table created in the database (id, name,comment)

alert.php

alert ("<?php echo $alert;?>");


guestbook.php (blocks)

Add entryName:Review:Write in the guest book<?phpif (!empty($_POST["button_guestbook"])) {$name =  htmlspecialchars ($_POST["name"]);$comment = htmlspecialchars ($_POST["comment"]);if ((strlen($name) < 3) || (strlen($comment) < 3)) $success = false;else $success = addGuestBookComment ($name, $comment);if (!$success) {$alert = "Ошибка при добавлении новой записи";include "alert.php";}}$comments = getAllGuestBookComments();for ($i = 0; $i < count($comments); $i++) {$name = $comments [$i] ["name"];$comment = $comments [$i] ["comment"];include "blocks/guestbook_comment.php";}?>










guestbook_comment.php (in the blocks folder)

<?php echo $name;?>:<?php echo $comment;?>


function.php

getAllGuestBookComments function () { global $mysqli; connectDB(); $result_set = $mysqli->query("SELECT * FROM `guestbook`"); closeDB(); return resultSetToArray($result_set); } addGuestBookComment function ($name, $comment) { global $mysqli; connectDB(); $success = $mysqli->query("INSERT INTO `questbook` (`name `comment`) VALUES ('$name', '$comment')"); closeDB(); return $success; }
by | 9 views

1 Answer

0 like 0 dislike
on the basis of checks:
if ((strlen($name) <3) || (strlen($comment) < 3 )) $success = false;

suppose that the length of the name or comment less than 3 characters

PS and what tag PHPMYADMIN ?
by

Related questions

0 like 0 dislike
3 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,457 users