Escolar Documentos
Profissional Documentos
Cultura Documentos
php
$msg = [];
$login = null;
$erro = 0;
if (strlen($login) == 0){
$erro++;
array_push($msg, "O campo 'login' é obrigatorio");
}
elseif (strlen($login) < 6 or strlen($login) > 20){
$erro++;
array_push($msg, "O número de caracteres é invalido");
}
if (strlen($pass) == 0){
$erro++;
array_push($msg, "O campo senha é obrigatorio");
}
elseif ($pass !== $pass_c){
$erro++;
array_push($msg, "A confirmação de senha e diferente");
}
if ($sql->fetchColumn()){
$erro++;
array_push($msg, "Esse login(".$login.") já foi utilizado");
}
if ($result)
{
array_push($msg, "O usuário foi criado com sucesso!");
}
}
}
}
?>
<!DOCTYPE html>
<html lang="pt_BR">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registro</title>
</head>
<body>
<?php
if ($msg != null and is_array($msg))
{
foreach ($msg as $value)
{
echo "<p>", $value, "</p>";
}
}
?>
<form method="POST">
<label for="login">Login:</label>
<input type="text" value="<?=$login?>" id="login" name="login"><br>
<label for="password">Password</label>
<input type="password" id="password" name="pass"><br>
<label for="password">Confirmação de Password</label>
<input type="password" id="password" name="pass_c"><br>
<button type="submit">Registro</button>
</form>
</body>
</html>