Honeypot protection with Ajax -
recently got attacked nasty auto-form fill bots filled shout form sorts of spam. shout form consist html file 2 textboxes,an ajax script(for refreshing without reloading) , php file handling inserting data db.
i thinking implementing hidden textbox minimum protection against these bots no luck since cant pass honeypot data php file. code:
html form
<form class="form" method="post" action="postdata.php"> <fieldset id="inputs"> <input id="name" name="name" type="text" placeholder="name" maxlength="20"> <textarea id="message" name="message" type="text" placeholder="message" maxlength="255"></textarea> </fieldset> <fieldset id="actions"> <input type="submit" id="submit" value="submit"> </fieldset> </form> ajax script
$(function(){refresh_shoutbox();$("#submit").click(function(){var a=$("#name").val();var b=$("#message").val();var c="name="+a+"&message="+b;$.ajax({type:"post",url:"postdata.php",data:c,success:function(d){$("#shout").html(d);$("#message").val("");$("#name").val("")}});return false})}); function refresh_shoutbox(){var a="refresh=1";$.ajax({type:"post",headers:{"cache-control":"no-cache"},url:"postdata.php",data:a,success:function(b){$("#shout").html(b)}})}; postdata.php file
<?php if($_post['name'] or $_post['message']) { $name= $_post['name']; $message= $_post['message']; ///do other stuff///// ?> i insert hidden field in html form
<input id="email" name="emails" style="display:none"></br> but cant manage pass value existing ajax script.tried code no luck. can shoutbox , running again?
Comments
Post a Comment