I am trying to stop bots posting to a site. We run Googles reCaptcha (v2) and a Honeypot but these are ineffective. I suspect they are using xRumer.
Regardless, until I have Google reCaptcha Beta 3 set up, I wanted to do a simple check to not allow a submission if the email text field contains "@mail.ru" since most submissions are matching this value in the email field.
Simple enough but it's not working. I reviewed this other StackOverflow post but !== also does not work.
It's got to be something simple but I can't see it.
First we check to see if the form is submitted. Then look at the last 8 characters to see if they match "@mail.ru". We also echo the value to confirm the comparison is correct, but it's still allowing the Do Something area.
<?php if ($_SERVER["REQUEST_METHOD"] == "POST") {
// post so do check
$emailCheck = substr($_POST['email'], -8);
if ($emailCheck !== '@mail.ru'); {
?>
Do something - only Insert if NOT match on $emailCheck
Close Check
<?php } } ?>
HTML
<form name="form1" method="post" action="">
<p> </p>
<p><input name="email" type="text" id="email"></p>
<p> </p>
<p>
<input type="submit" name="submit" id="submit" value="Submit">
</p>
<p>Email Check: <?php echo $emailCheck; ?></p>
</form>
As noted by @Qirel there was an error in the code which was a closing semicolon
if ($emailCheck !== '@mail.ru'); {
prior to the opening Brace.
Xrumer still thwarts our attempts to block spam posts but at least this question is accurately answered.