Forgot Password / Register
Site Statistics
Total Members: 509
Total Tutorials: 242
Newsest User: Lestop
Todays Unique Hits: 91
1 Users 1 Guests Online

User System (Part 2)

Want to stop people registering on your site with names they shouldn't be using?
This tutorial will allow you to create a list of username which cannot be used during the signup process.

For this tutorial I will assume you already have folled the User System (Part 1) tutorial and this is working correctly.

Once you have that continue,

On Register.php find,
1
2
3
if(mysql_num_rows($cname) >= 1) { // If account with username already exists then do not continue
    echo "The username is already in use"; 
}


Before this add:
1
2
3
4
5
6
7
$blockedusernames = array("Bad Name 1","Bad Name 2","Bad Name 3");
if(in_array($username,$blockedusernames)) {
    $detected = "True";
}
if($detected == 'True') {
    echo "Bad username detected, Please use a different username.";
} else


This is a very simple yet effective way to stop people using usernames, you can add as many blocked names as you like to the array.
DanielXP
Author:
Views:
2442
Rating:
Posted on Sunday 9th March 2008 at 03:36 AM
Diablosblizz
Diablosblizz
New2Old post your full register.php in the forums so we can have a better look at it.
Posted on Sunday 9th March 2008 at 02:31 AM
new2old
new2old
sort of works, it doesnt add the user to the database, but i still get the success message saying registration complete
Posted on Friday 1st June 2007 at 08:51 PM
MCP
MCP
Great tutorial. Thanks ;)
Posted on Sunday 11th March 2007 at 01:21 AM
sarye
sarye
Oh okay. Thankies! :D

~Nae
Posted on Saturday 10th March 2007 at 10:23 PM
Joe
Joe
Thanks I really needed this tut
Posted on Saturday 10th March 2007 at 09:36 PM
DanielXP
DanielXP
No this will detect a bad name and then block the rest of the code from running and registering and makes them go back to enter a new username.
Posted on Friday 9th March 2007 at 09:34 PM
sarye
sarye
We replace the Bad names with the names we want blocked right?

~Nae
Posted on Thursday 8th March 2007 at 08:04 PM
DanielXP
DanielXP
This scripts detects what ever phrase is in the array so if some one entered MOD-Dan and you have MOD in your array it will detect it.
Posted on Thursday 8th March 2007 at 05:40 PM
MOD-Dan
MOD-Dan
Hey dude is there any way so that instead of blocking names you could have it so it blocks the perfix MOD- or MOD