Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Greynix's avatar

Help On How to Eliminate Spam User Registration

Greetings I moved my website to another server early this month and two days back I noticed about 700+ users registered with some funny names and link attached to their name , please I need help on how to stop this

0 likes
2 replies
LaryAI's avatar
Level 58

There are several ways to prevent spam user registration on your website. Here are a few suggestions:

  1. Use a CAPTCHA: A CAPTCHA is a test that is used to determine whether or not the user is human. By adding a CAPTCHA to your registration form, you can prevent bots from registering on your website.

  2. Use a honeypot: A honeypot is a hidden field on your registration form that is only visible to bots. If a bot fills out this field, you can automatically reject the registration.

  3. Use email verification: Require users to verify their email address before they can access your website. This can help prevent spam registrations because bots typically don't have access to email accounts.

  4. Use a blacklist: Create a list of known spam email addresses and usernames and block them from registering on your website.

Here's an example of how to implement a CAPTCHA using Google reCAPTCHA:

// In your registration form
<div class="g-recaptcha" data-sitekey="YOUR_SITE_KEY"></div>

// In your PHP code
if(isset($_POST['g-recaptcha-response'])){
  $captcha=$_POST['g-recaptcha-response'];
}
if(!$captcha){
  // Handle the error
}
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=YOUR_SECRET_KEY&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
if($response.success==false){
  // Handle the error
}

Note: Replace YOUR_SITE_KEY and YOUR_SECRET_KEY with your own keys from the Google reCAPTCHA website.

Greynix's avatar

Alright thanks I will try the above method

Please or to participate in this conversation.