Forums
This topic is locked
Form Validation
Posted 17 Oct 2001 11:59:35
1
has voted
17 Oct 2001 11:59:35 Michael O'Neill posted:
Me again!I am trying to restrict the characters that a user can enter for a username. I am using something similar to the test code below that does not allow certain characters.
Is there a better way of doing this?
Thanks
Mike.
if(isset($varusername))
{
$varusername = trim($varusername);
$varusername = strip_tags($varusername);
echo $varusername."<br>";
if (strlen($varusername) >= 6)
if (!eregi("[\$\"\\-_=&£%!#~@;:\.\,?\^\|\{\}\(\)\*\+]",$varusername))
{
echo "ok";
}
}
?>
Replies
Replied 18 Oct 2001 01:41:23
18 Oct 2001 01:41:23 Tim Green replied:
Seems to me that you are covering all the angles here. I don't see a problem at all with this code.
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>