Hypothetically, if I didn't want to allow the word "douche" anywhere in a username and I have a table in my database with all of the prohibited words...
$q = "SELECT * FROM restrictions WHERE prohibited LIKE '%username%'";
$r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc));
if (mysqli_num_rows($r) !== 0)
{
//username is prohibited
echo "invalid";
}
else
{
...etc
The problem is that I don't know how to execute a query that would pick up partial matches (ie. Jdoucher, or douchebag4). The %username% part is obviously wrong, I know. Does anyone know how to do this? Is it even possible? Thanks.
select *
from restrictions
where locate(prohibited, @username) <> 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With