Erik_Fischer Posted August 27, 2013 Share Posted August 27, 2013 I'm trying to create a comment section for my website and need to make it so that after the person submits a comment (and it contains errors), it will show the error (a new HTML element) without refreshing the page. I know almost nothing of AJAX/JQuery, so I'll need some help.Here's what I have so far: <?php if(isset($_POST['reply_submit'])) { $reply = $_POST['new_reply']; $reply_message = ""; if(empty($reply)) { $reply_message = "Your comment is too short."; } } ?> <html lang="en"> <body> <form class="no-margin" method="POST" action=""> <textarea name="new_reply" placeholder="Write a reply..."></textarea> <button name="reply_submit" class="btn post-button" type="submit">Post' . (isset($reply_message) ? '<div class="comment-warning">' . $reply_message . '</div>' : '') . '</button> </form> </body> </html> So what I need it to do is, if the person's comment box doesn't meet the criteria (in this case, an empty field), I need it to show this error line without refreshing the page: <button name="reply_submit" class="btn post-button" type="submit">Post' . (isset($reply_message) ? '<div class="comment-warning">' . $reply_message . '</div>' : '') . '</button> Please help. Link to comment https://forums.phpfreaks.com/topic/281587-show-error-without-page-refresh/ Share on other sites More sharing options...
jazzman1 Posted August 31, 2013 Share Posted August 31, 2013 In fact, there is a ton of tutorials on the web. Google -"Ajax/jQuery/PHP" Link to comment https://forums.phpfreaks.com/topic/281587-show-error-without-page-refresh/#findComment-1447578 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.