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
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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.