Jump to content

Need help with eregi function ^^


Zimi

Recommended Posts

Hello

I'm trying to use the eregi function to make sure a string entered by the user is valid (only English letters, numbers, "_" and "-".

This is my first time using eregi and regular expressions so I have no idea what's the problem with my code:

 

function Vaild_Login($Login_Name)
{
if(eregi('[^A-Za-z0-9_-]', $Login_Name))
{
return True;
}
else
{
return False;
}
}

 

Any help would be appraised ^^

Link to comment
https://forums.phpfreaks.com/topic/110992-need-help-with-eregi-function/
Share on other sites

Fast replay lol, thanks ^^

But still not working, the code looks like this:

function Vaild_Login($Login_Name)
{
if(eregi("^[A-Za-z0-9_-]$", $Login_Name))
{
return True;
}
else
{
return False;
}
}

And the other end:

if(Vaild_Login($Login_Name) == False && $Login_name != "")
	{
	echo "You have submitted an invaild Login Name";
                }

 

Oh, sorry for putting the topic in the wrong place =x

 

Archived

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

×
×
  • Create New...

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.