Erik_Fischer Posted August 27, 2013 Share Posted August 27, 2013 (edited) 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. Edited August 27, 2013 by Erik_Fischer Quote 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" Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.