php - Validation of not allowed username string in input form -
php - Validation of not allowed username string in input form -
i have collection of string stored in database table separated comma.
table "not_allowed" content :
admin,administrator,register,email,password,username,database,computer,... etc. (as admin defind)
in user registration, want collection of string "not allowed" username input.
how create validation in php in relation database table content?
manual scipt have :
$notallowed = array('admin','administrator','register','email','password','username','database','computer',... etc); if (in_array($username, $notallowed, true)) { $errors[] = 'the selected username not allowed! '; }
create table in db called not_allowed
. utilize store not allowed strings. when user signs in, query table not allowed strings. store result in variable , utilize in same way utilize now.
depending on programme construction can done in different ways, here's basic thought using mysqli:
$query = $mysqli->query("select * not_allowed"); $not_allowed = $query->fetch_array(); if (in_array($username, $not_allowed, true)) { $errors[] = 'the selected username not allowed! '; }
php mysql
Comments
Post a Comment