Forum Moderators: coopster

Message Too Old, No Replies

validation on name

         

sfast

4:37 pm on Mar 27, 2007 (gmt 0)

10+ Year Member



My code shows me illegal input name even if I am entering just == abcdef

Can somebody please guide me where am I wrong?


extract($_POST);

// **** Validation for name */
if(!check_name($POST_['name'])){
echo "Illegal input name";
$error++; }
else
$userName = $POST_['name'] ;

} // end of process check

function check_name($name)
{
$pattern = "/^[-A-Za-z]+$/";
if (! preg_match($pattern, $name) ) {
return false; }
else
return true;
}

Thanks

sfast

4:48 pm on Mar 27, 2007 (gmt 0)

10+ Year Member



I got it working.
The problem was with POST syntax.

Thanks

joelgreen

6:14 pm on Mar 27, 2007 (gmt 0)

10+ Year Member



Why do you need extract($_POST) if you access variables via $_POST array?

eelixduppy

12:33 am on Mar 28, 2007 (gmt 0)



Glad you got it sorted, sfast! :)

>> exract($_POST)

Not used here therefore it's not needed.