The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Quick question with php
Sinario:
I have a banned user table in my database When a user signs up I want to check the username against this list. in database banned usernames test admin mod I can do this with: Code:
if (mysql_num_rows($ban_username_exists) != '0') for example if the user tried to register test1, test_now, testtaco admin_me, admin1, adminme mod1,mod_me,modme What code would I use to pickup these partials ? |
#2
|
|||
|
|||
PHP Code:
|
#3
|
|||
|
|||
Hey,
Thanks for the quick response. This is for another app not vbulletin. I know I can check the database for the username entered , but what if they use part of a username that exsist for example admin is banned what if they try to register admin1 or adminMe |
#4
|
|||
|
|||
Use mysql wildcards like this.
[sql]SELECT * FROM banlist WHERE username = '%$username%'[/sql] |
#5
|
|||
|
|||
Hey,
No that didn't work. It returned for example: admin as a banned username , but when I tried admin1 it still let admin1 be registered as a user |
#6
|
|||
|
|||
Sorry it should use a like then a equal sign.
[sql]SELECT * FROM banlist WHERE username LIKE '%$username%'[/sql] |
#7
|
|||
|
|||
Hey still not working
Here is what I have full code.. Code:
require_once ('js/xajax_core/xajax.inc.php'); $xajax = new xajax(); $xajax->registerFunction("processForm"); function processForm($username) { $ban_username_exists = sql_query("SELECT * FROM banned_usernames WHERE banned_username = '" . $username . "'"); $result = sql_query(sprintf("SELECT * FROM users WHERE username = '%s'", $username)); $banned = sql_query("SELECT * FROM usernames WHERE banned_username = '" . $username . "' LIKE '" . $username % "'"); $objResponse = new xajaxResponse(); if (empty($username)) { $objResponse->assign("result", "innerHTML", '<span style="color:#f00"><font size="2">Username Empty</font></span>'); } elseif (!preg_match("/^[a-zA-Z\d\-_]+$/i", $username)) { $objResponse->assign("result", "innerHTML", '<span style="color:#f00"><font size="2">Invalid Username - Invalid Character or Space</font></span>'); } elseif (mysql_num_rows($ban_username_exists) != '0') { $objResponse->assign("result", "innerHTML", '<span style="color:#f00"><font size="2">Invalid Username - Banned Username</font></span>'); } elseif (mysql_fetch_row($banned)) { $objResponse->assign("result", "innerHTML", '<span style="color:#f00"><font size="2">Invalid Username - Banned Username</font></span>'); } elseif (mysql_num_rows($result) > 0) { $objResponse->assign("result", "innerHTML", '<span style="color:#f00"><font size="2">Not Available</font></span>'); } else { $objResponse->assign("result", "innerHTML", '<span style="color:#0c0"><font size="2">Available</font></span>'); } return $objResponse; } $xajax->processRequest(); Other then the mySQL wildcard is there anyway of matching any username that would have part of a banned username? maybe a reg expression ? |
#8
|
|||
|
|||
Does AdminCP > vBulletin Options > vBulletin Options > User Registration Options > Illegal User Names not cover what you want to do?
|
#9
|
|||
|
|||
No. As I said in the third post in this thread. It is not a vbulletin site therefore the vbulletin option can not be used.
I am just asking for a little help |
#10
|
|||
|
|||
Ah right must have missed that post.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|