Jump to content

Archived

This topic is now archived and is closed to further replies.

dharm

how can i check characters using Ereg()

Recommended Posts

Hi, can anyone help!.. im trying to check the characters of a username and password but cant seem to check the whole field, only the first letter. Here is the code
Please tell me where im going wrong..

$UserNameGood = chk_chars($username1);
//}
if ($UserNameGood == true) {
echo "username is good";
}else {
echo "username is bad";
}
// $PassWordGood = chk_chars($password1);

function chk_chars($inputVar) {

$charsGood = true;
if (!ereg("^[A-Za-z0-9_-]",$inputVar))
{
$charsGood = false;
}
return $charsGood;
}

Thx!

Share this post


Link to post
Share on other sites
found the problem.. i was missing +$ within (!ereg("^[A-Za-z0-9_-]+$",$inputVar)).. hehe!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.