[Tool/Web/Other] Sistema de registro pela web - Primeiro script PHP
#1

PHP код:
<html>
<title>Sistema de Registro</title>
<body bgcolor = "black" align = "center">
<font color = "#ffa500" face = "Verdana">
<h2>Registro</h2>
<?php
if(isset($_POST['registrar']))
{
    if(
strlen($_POST['nome']) >= && strlen($_POST['nome']) <= 24)
    {
        if(
strlen($_POST['senha']) >= && strlen($_POST['senha']) <= 32)
        {
            if(
$_POST['senha'] == $_POST['rsenha'])
            {
                
$conectar mysql_connect("localhost""root""") or die(mysql_error());
                
mysql_select_db("rpg"$conectar);
                
                
$nome mysql_real_escape_string($_POST['nome']);
                
                
$query mysql_query("SELECT * FROM player_info WHERE name = '$nome'"$conectar) or die(mysql_error());
                
$rows mysql_num_rows($query);
                if(!
$rows)
                {
                    
mysql_query("INSERT INTO player_info (name, password) VALUES ('$nome','$senha')"$conectar) or die(mysql_error());
                    
$id mysql_insert_id($conectar);
                    echo 
"Registrado com sucesso.<br>";
                    echo 
"Vocк recebeu seu id interno: $id<br><br>";
                }
                else
                {
                    echo 
"Erro: Jб hб um usuбrio cadastrado com este nome.<br>";
                    echo 
"Caso seja vocк faзa login.<br><br>"// Criar login
                
}
            }
            else echo 
"Erro: Senha e confirmaзгo sгo diferentes.<br><br>";
        }
        else echo 
"Erro: Sua senha deve conter entre 5 e 32 caracteres.<br><br>";
    }
    else echo 
"Erro: Seu nome deve conter entre 5 e 24 caracteres.<br><br>";
}
?>

<form method = "post" action = "">
    Nome:<br><input type = "text" name = "nome"><br>
    Senha:<br><input type = "password" name = "senha"><br>
    Confirmar senha:<br><input type = "password" name = "rsenha"><br><br>
    <input type = "submit" name = "registrar" value = "Registrar">
</form>
</font>
</body>
</html>
LOL fui editar acabei apagando a introduзгo, quem tiver problema pra criar a tabela o cуdigo estб feito abaixo:

Код:
create table if not exists player_info (id int(11) not null auto_increment, name varchar(24) not null, password varchar(32) not null);
Agora o script funciona com uma ъnica pбgina.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)