Показать сообщение отдельно

  #9  
Старый 20.06.2009, 21:23
b3
Постоянный
Регистрация: 05.12.2004
Сообщений: 647
Провел на форуме:
1698585

Репутация: 818


По умолчанию

В чем ошибка? Пересидел чтоли, немогу расчехлится. Регулярки пропускают лшюбые значения если вначале вводить двойные ковычки
PHP код:
<?php
$sysmessage 
'';
function 
Form()
{
    global 
$sysmessage;
    echo 
'
<table border="1" align="center">
<form method="post" enctype="application/x-www-form-urlencoded">
<tr>
    <td colspan="2" align="center">'
.$sysmessage.'Регистрация</td>
    
</tr>
<tr>
    <td>Логин</td>
    <td><input type="text" align="CENTER" size="30" maxlength="30" name="login" /></td>
</tr>
<tr>
    <td>Пароль</td>
    <td><input type="password" align="CENTER" size="30" maxlength="30" name="password" /></td>
</tr>
<tr>
    <td>Повтор пароля</td>
    <td><input type="password" align="CENTER" size="30" maxlength="30" name="password2" /></td>
</tr>
<tr>
    <td>Имейл</td>
    <td><input type="text" align="CENTER" size="30" maxlength="30" name="email" /></td>
</tr>
<tr>
    <td colspan="2" align="center"><input type="submit" value="register" /></td>
    
</tr>
</form>
</table>
'
;
}
if(empty(
$_POST['login']) || empty($_POST['password']) || empty($_POST['password2']) || empty($_POST['email']))
{
Form();
exit;    
}
if(
$_POST['password'] != $_POST['password2'])
{
$sysmessage =  '<font color="red"><b>Пароли не совпадают</b></font><br>';
Form();
exit;    
}
$login htmlspecialchars($_POST['login']);
$password htmlspecialchars($_POST['password']);
$password2 htmlspecialchars($_POST['password2']);
$email htmlspecialchars($_POST['email']);
##
if(!preg_match('#[a-z0-9]{3,20}#i'$login))
{
    
$sysmessage '<font color="red"><b>Неправильный формат Логина</b></font><br>';
    
Form();
    exit;
}
##
if(!preg_match('#[a-z0-9_]{6,20}#i'$password))
{
    
$sysmessage '<font color="red"><b>Неправильный формат Пароля</b></font><br>';
    
Form();
    exit;
}
##
if(!preg_match('#[\.\-_A-Za-z0-9]+?@[\.\-A-Za-z0-9]+?[\.A-Za-z0-9]{2,}#'$email))
{
    
$sysmessage '<font color="red"><b>Неправильный формат Имейла</b></font><br>';
    
Form();
    exit;
}

echo 
"login: $login<br>password: $password<br>email: $email";

?>

Последний раз редактировалось b3; 20.06.2009 в 21:34..
 
Ответить с цитированием