While developing a login section , i got an error .
The result always shows up the false statement.what's wrong with this code
Could anyone guide me through "preg_match",Wolud like to know preg_match in detail.
The code is :
if (isset($_POST['submit']))
{
if (preg_match('%^[A-Za-z0-9]\S{8,20}$%', stripslashes(trim($_POST['userid']))))
{
$u = $_POST['userid'];
echo $u.'<br />';
}
else
{
$u = FALSE;
echo '<p><font color="red" size="+1">Please enter a valid User ID!</font></p>';
}
if (preg_match ('%^[A-Za-z0-9]\S{8,20}$%', stripslashes(trim($_POST['password']))))
{
$p =$_POST['password'];
$p=sha1($p);
echo $p;
}
else
{
$p = FALSE;
echo '<p><font color="red" size="+1">Please enter a valid Password!</font></p>';
}
}
%^[A-Za-z0-9]\S{8,20}$%
Means:
1 of A-Z or a-z or 0-9 8 through 20 of \S
I doubt that's what you meant?
Perhaps try the \S in the []