Advertisement
iSmirnoff

[PHP] Registro Online

Sep 19th, 2013
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.03 KB | None | 0 0
  1. <?php
  2.  
  3.     $USUARIO = "root" ;
  4.     $SENHA = "";
  5.     $BD = "SAMP";
  6.     $HOST = "localhost";
  7.  
  8.     mysql_connect ($HOST, $USUARIO, $SENHA ) or die (mysql_error());
  9.     mysql_select_db ($BD) or die (mysql_error());
  10. ?>
  11.  
  12.  
  13. <?php
  14. if(isset($_POST['acao'])) {
  15.    
  16.     $user      = $_POST['nick'];
  17.     $email     = $_POST['email'];
  18.     $password  = $_POST['senha'];
  19.     $bool      = false ;
  20.  
  21.     if ( $user == "" or substr_count ( $user, "_" ) != 1 )  
  22.     {
  23.         echo "<script>alert ('Campo Nome, incorreto. Use Nick_Sobrenick'); location.href='index.php'</script>";
  24.         $bool = true ;
  25.     }
  26.     if ( $email == "" or substr_count ($email, "@")  != 1 or substr_count ($email, ".")  > 3 )
  27.     {
  28.         echo "<script>alert ('Campo E-mail, incorreto. Exemplo: example@email.com'); location.href='index.php'</script>";
  29.         $bool = true ;
  30.     }
  31.     if ( $password == "" )
  32.     {
  33.         echo "<script>alert ('Preencha o campo Senha'); location.href='index.php'</script>";
  34.         $bool = true ;
  35.     }
  36.     if ( strlen ( $password) > 21 or strlen ( $password ) < 5 )
  37.     {
  38.         echo "<script>alert ('Senha deve ser entre 5 e 21'); location.href='index.php'</script>";
  39.         $bool = true ;
  40.     }
  41.     if ( strlen ( $user) > 21 or strlen ( $user ) < 5 )
  42.     {
  43.         echo "<script>alert ('Usuário deve ser entre 5 e 21'); location.href='index.php'</script>";
  44.         $bool = true ;
  45.     }
  46.     if ( $bool == false )
  47.     {  
  48.         $verificaUsuario = mysql_query("SELECT * FROM usuarios WHERE Nick = '$user' AND Email = '$email'");
  49.            
  50.         if(mysql_num_rows($verificaUsuario) > 0)   {
  51.            
  52.            $bool = true ;
  53.             echo "<script>alert ('Nome de usuário ou e-mail já está cadastrado');</script>";
  54.         }    
  55.         else   {
  56.        
  57.             $bool = true ;
  58.             mysql_query("INSERT INTO `usuarios` ( `Nick`, `Password`, `Email`) VALUES ( '$user', '$password', '$email')") or die (mysql_error());
  59.            
  60.             echo "<script>alert ('Nick registrado com Sucesso: Nick: $user Senha: $password E-mail: $email'); location.href='index.php'</script>";
  61.         }
  62.     }
  63. }
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement