Feedback Form Script with Captcha Code

Feedback Form Script with Captcha Code

If you are looking for Feedback Form Script with Captcha Code in PHP then you are at the right place. I will teach you to step by step on how to create a feedback form with captcha code using PDO in PHP. Also, you can learn how to generate a random code and you can use this to protect your web page from random spammers. You can use this also as a type of a simple test that the response is generated by a human being and it's a very common on other websites before submitting the feedback message to their websites.

Creating Markup Feedback Form

This simple source code contains feedback form where the user can type their message, full name and email to send into the websites.
  1. <form class="form-horizontal" style="margin-left:360px;" method="POST" action="contact_query.php">
  2. <h2>
  3. Feedback Form with Captcha
  4. </h2>
  5. <p class="full_name">
  6. <input type="text" name="full_name" id="full_name" placeholder="Enter your full name . . . ." autofocus="autofocus" required/>
  7. <label for="full_name" style="color:blue; font-size:18px; font-family:cursive; margin-top:10px;">Your Name</label>
  8. </p>
  9.  
  10. <p class="email">
  11. <input type="email" name="email" id="email" placeholder="Enter your email . . . ." required/>
  12. <label for="email" style="color:blue; font-size:18px; font-family:cursive; margin-top:10px;">Your Email Address</label>
  13. </p>
  14.  
  15. <p class="message">
  16. <textarea name="message" placeholder="Enter your feedback . . . ." required></textarea>
  17. <label for="message" style="color:blue; font-size:18px; font-family:cursive; margin-top:10px;">Your Feedback</label>
  18. </p>
  19.  
  20. <div class="control-group" style="margin-left:-181px;">
  21. <div class="controls">
  22. <input id="code" name="code_confirmation" type="text" placeholder="Enter the code above . . . ." required></td>
  23. </div>
  24. </div>
  25. <div class="control-group" style="margin-left:-181px;">
  26. <div class="controls">
  27. <button type="submit" name="send_message" class="btn btn-primary"><i class="icon-ok icon-large"></i> Submit</button>
  28. </div>
  29. </div>
  30.  
  31. </form>

Captcha Code

Creating captcha code for the confirmation before submitting their feedback message to the websites.
  1. <div class="control-group" style="float:left; margin-left:-185px;">
  2. <div class="controls">
  3.  
  4. <img src="generatecaptcha.php?rand=<?php echo rand(); ?>" name="captcha_img" id='image_captcha' >
  5. <a href='javascript: refreshing_Captcha();'><i class="icon-refresh icon-large"></i></a>
  6. <script language='JavaScript' type='text/javascript'>
  7. function refreshing_Captcha()
  8. {
  9. var img = document.images['image_captcha'];
  10. img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
  11. }
  12. </script>
  13. </div>
  14. </div>

Database Connection

  1. <?php
  2.  
  3. $conn = new PDO("mysql:host=localhost;dbname=feedback_form", 'root', '');
  4.  
  5. ?>

Output

Result That's it, kindly click the "Download Code" button below for the full source code. Enjoy coding. Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.

Comments

Submitted byMohammad Aquib (not verified)on Fri, 03/24/2017 - 10:49

hello sir your feed back form nice design I want changes your feed back form captcha size

Add new comment