R0CKY Posted August 8, 2009 Share Posted August 8, 2009 I have a script installed that has a comment form that I want to protect from spam with a simple math question. I added a new field into the form called antispam, and in the form processor page I added a check for the answer to be correct. I can't get it to work though. By a process of trial and error though I discovered I can get a condition check to work if I use one of the existing fields. For example if I change the condition check to only proceed if the subject field is "PASS", then it will work. But as soon as I try and use the new antispam field, it does not work, whether the answer is correct or wrong, it still pasts the comment. This confuses me. Here's the code I am using. I have commented in <!-- ANTI SPAM ROW --> to show the only 4 lines of code I inserted into this form. The form <form action="{$settings.dburl}/index.php?act=comments&c=post&file={$file.file_id}" method="post"> <table width="75%" border="1" align="center" cellpadding="3" cellspacing="0" class="border"> <tr class="sectionheader"> <td width="100%" colspan="2"> {#post_comment#} </td> </tr> <tr> <td width="50%">{#poster#}:</td> <td width="50%"><input type="text" name="subject" id="subject" size="40" maxlength="150" /></td> </tr> <tr> <td align="center" colspan="2"> <textarea name="comment" id="comment" rows="12" style="width: 95%"></textarea> </td> </tr> <!-- ANTI SPAM ROW --> <tr> <td width="50%">Anti Spam : What is 2 + 2?</td> <td width="50%"><input type="text" name="antispam" id="antispam" size="1" maxlength="1" /></td> </tr> <tr> <td align="center" colspan="2"> <input type="submit" value="{#post_comment#}" onclick="postComment({$file.file_id}); return false;" /><br /> <div id="status" style="font-weight: bold"></div> </td> </tr> </table> </form> The Form Processor In this page I added a simple check if ($_POST['antispam'] == "4") $enableComments = true; This does not work though. However if I was (just for testing purposes) to do a check on the subject field (as follows) it works! if ($_POST['subject'] == "SPAM") $enableComments = false; So I have figured out the problem is with the new antispam field I added - but what is the problem? Many thanks for any advice on this one. Quote Link to comment Share on other sites More sharing options...
abazoskib Posted August 8, 2009 Share Posted August 8, 2009 try this: if ($_POST['antispam'] == 4) $enableComments = true; Quote Link to comment Share on other sites More sharing options...
R0CKY Posted August 8, 2009 Author Share Posted August 8, 2009 Hi thanks for the suggestion, but it made no difference. Quote Link to comment Share on other sites More sharing options...
abazoskib Posted August 8, 2009 Share Posted August 8, 2009 what happens when you echo $_POST['antispam'] ? you should seethe number you entered. Quote Link to comment Share on other sites More sharing options...
R0CKY Posted August 8, 2009 Author Share Posted August 8, 2009 Yeh I tried that but I don't see the echo anywhere, the page refreshes really quick, the comment appears posted and there is no echo in sight. I think I need to try and stop the code somewhere (somehow) so I get time to see the echo. I just know that it won't display the spam field, but you are right we need to see, I'm going to dig a bit deeper. Quote Link to comment Share on other sites More sharing options...
abazoskib Posted August 8, 2009 Share Posted August 8, 2009 you should see it regardless. post more code from your form processor. Quote Link to comment Share on other sites More sharing options...
R0CKY Posted August 10, 2009 Author Share Posted August 10, 2009 It's getting to confusing for me as a php n00b to follow, I found that there are apparently two form processors in this downloads system, one called ajax.php and one called ajax.js :-\ I think I am going to have to give up on this and find another way to stop the spammers. Quote Link to comment 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.