Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Validation Script - Detecting Illegal Characters, preg_match to find illegal characters
sonesay
post Jul 11 2007, 10:50 PM
Post #1


|||[ n00b King ]|||
*********

Group: [HOSTED]
Posts: 688
Joined: 20-June 07
From: Auckland
Member No.: 45,102



I'm trying to validate a user's desired username for a registration page. I want to detect any illegal characters being used for a username. So far i have managed to include most execpt the '\', the '\' is used for escape and treating the preceding characters literally. I try to do '\\' but i get an error because it execects another character.

CODE
$ck_result = "Default";
$pattern = "/[!|@|#|$|%|^|&|*|(|)|_|\-|=|+|\||,|.|\/|;|:|\'|\"|\[|\]|\{|\}]/i";
    
// check for input
if($uname == '') {
$ck_result = "<span class='error_header'>Required!</span>";
}
else if (preg_match($pattern, $uname)) {
$ck_result = "<span class='error_header'>illegal characters</span>";
}


I have tried looking for more info but havent found any so far.

Notice from BuffaloHELP:
Always use proper bbcode tags. Title modified.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Many Php Script Sites(16)
  2. Script: Php Jukebox(4)
  3. Parse: Error Unexpected T_lnumber(4)
  4. Watermark Your Image With Simple Php Script(35)
  5. Wappychat_oldskool(15)
  6. Free Auction Script(6)
  7. Wappy Buddy V1.10 - Tibia Gold Edition By Wappy & Jon Roig(3)
  8. What Kind Of Script Do You Need ?(15)
  9. Creatting A Playlist Through Php(5)
  10. Very Simple Online Now Script(4)
  11. Html Code Tester. Online Script(15)
  12. Converting Textarea Return Characters To <br />(9)
  13. Php Downloads Script(4)
  14. Script Help Required: Undefined Variable(3)
  15. Library Script(6)
  1. How Would I Go About Making A Simple "counting" Script?(3)
  2. Forum Script(3)
  3. Php Rediret Script(12)
  4. Download Script For Mp3 Files(0)
  5. How Do I Connect To Live Database With Php Script?(6)
  6. Need Help Installing Dolphin Community Script!(5)
  7. Php Preg Replace(1)
  8. Preg Replace Problem(1)
  9. Guessing Php Script(2)
  10. A Simple Preg_replace Help Please.(2)
  11. How To Make A View New Post Script?(5)
  12. Php Guest Online Script(3)
  13. How To Make Php Newsletter Script(3)


 



- Lo-Fi Version Time is now: 13th October 2008 - 01:58 PM