note 87843 added to function.preg-match

From: Date: Fri, 26 Dec 2008 07:19:55 +0000
Subject: note 87843 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-148512@lists.php.net to get a copy of this message
I have read through so many tutorials etc but this just isnt working. Can somone explain why this wont work?: Trying to check that user input just contains characters and no numbers. To start with. Then would like to make sure they dont use % . / @ etc so they cant inject sql. Here is what I try to use : <code> $name = $_POST['name']; if(preg_match('/[a-z][^0-9]/', $name)) { echo $name; } else { echo 'error'; } </code> ---- Server IP: 87.124.35.190 Probable Submitter: 80.6.32.196 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match.php Edit -- https://master.php.net/note/edit/87843 Del: integrated -- https://master.php.net/note/delete/87843/integrated Del: useless -- https://master.php.net/note/delete/87843/useless Del: bad code -- https://master.php.net/note/delete/87843/bad+code Del: spam -- https://master.php.net/note/delete/87843/spam Del: non-english -- https://master.php.net/note/delete/87843/non-english Del: in docs -- https://master.php.net/note/delete/87843/in+docs Del: other reasons-- https://master.php.net/note/delete/87843 Reject -- https://master.php.net/note/reject/87843 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#148512) next »