-4

i really need help from you guys !! some of my friends are scamming on my website. like typing username : %%#&^$%#

i just want code that delete Row if harmful characters is found. if possible blocking users ip address. :)

spickywolf
  • 86
  • 7

1 Answers1

0
if (!preg_match("/[a-zA-Z0-9]+/", $username))
  Die ($username." is not allowed username here!")
diavolic
  • 722
  • 1
  • 4
  • 5
  • I hope I'll never have to use a website that communicates validation errors with `die`. – Bartosz Zasada Mar 27 '17 at 10:30
  • @diavolic thanks alot !! Am sure this code will work :) :) – spickywolf Mar 27 '17 at 10:31
  • if (!preg_match("/[a-zA-Z0-9]+/", $username)){ echo 'username without harmful character'; }else{ echo 'sorry'; } – spickywolf Mar 27 '17 at 10:34
  • 1
    While this code snippet may solve the question, [including an explanation](http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. – DimaSan Mar 27 '17 at 11:20
  • People, if somebody trying to scam your script, using die for this user is preferable. No mercy for attackers – diavolic Mar 27 '17 at 11:58