4
Contributors
7
Replies
8
Views
10 Years
Discussion Span
Last Post by lydia21
0

validating in php really isn't that hard. i have been using this function for a while. i don't know if it is the best way but it works for me.

function check($fieldname)
{
  if(!preg_match("/[^a-zA-Z0-9\.\-\Ä\ä\Ö\ö\Ü\ü\,\
   ]+$/s",$fieldname)) {
    return TRUE;
}
else {
    return FALSE;
}
}
0

for numbers,you can use this function:

function checknumber($fieldname)
{

if (is_numeric($fieldname)==TRUE)//if it is a number..
{
return TRUE;
}
else
{
return FALSE;
}

}
0

for numbers,you can use this function:

function checknumber($fieldname)
{

if (is_numeric($fieldname)==TRUE)//if it is a number..
{
return TRUE;
}
else
{
return FALSE;
}

}

hi
this is not working for me...

0

If it doesn't work, you're not doing it right. Learn basic PHP skills before you post.

@ryan_vietnow: you might want to simplify that; the function returns what is_numeric does on it's own.
Just do something like

$x = $_GET['foo']; echo is_numeric($x);

@lydia21: you posted this same thread 3+ times...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.