I build a registration page with php. I have to check if username have alphanumeric symbols. So I did it:
$pattern = "[a-zA-Z0-9]{4,10}";
echo "Pattern = $pattern<br>";
echo "Username = $_POST[username]<br>";
echo "res = ";
echo ereg($pattern, $_POST['username']);
The last echo does not print! I try to use "hello" as username. it should be right! What is the problem?
";` without single quotation marks around `username`? Also, echo should print something, `ereg` returns either a match length, or `false`. Try something like `if (ereg ($pattern, $_POST['username'], $regs)) { echo "$regs[0]"; }` – Wiktor Stribiżew Apr 27 '15 at 13:16