Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $USUARIO = "root" ;
- $SENHA = "";
- $BD = "SAMP";
- $HOST = "localhost";
- mysql_connect ($HOST, $USUARIO, $SENHA ) or die (mysql_error());
- mysql_select_db ($BD) or die (mysql_error());
- ?>
- <?php
- if(isset($_POST['acao'])) {
- $user = $_POST['nick'];
- $email = $_POST['email'];
- $password = $_POST['senha'];
- $bool = false ;
- if ( $user == "" or substr_count ( $user, "_" ) != 1 )
- {
- echo "<script>alert ('Campo Nome, incorreto. Use Nick_Sobrenick'); location.href='index.php'</script>";
- $bool = true ;
- }
- if ( $email == "" or substr_count ($email, "@") != 1 or substr_count ($email, ".") > 3 )
- {
- echo "<script>alert ('Campo E-mail, incorreto. Exemplo: example@email.com'); location.href='index.php'</script>";
- $bool = true ;
- }
- if ( $password == "" )
- {
- echo "<script>alert ('Preencha o campo Senha'); location.href='index.php'</script>";
- $bool = true ;
- }
- if ( strlen ( $password) > 21 or strlen ( $password ) < 5 )
- {
- echo "<script>alert ('Senha deve ser entre 5 e 21'); location.href='index.php'</script>";
- $bool = true ;
- }
- if ( strlen ( $user) > 21 or strlen ( $user ) < 5 )
- {
- echo "<script>alert ('Usuário deve ser entre 5 e 21'); location.href='index.php'</script>";
- $bool = true ;
- }
- if ( $bool == false )
- {
- $verificaUsuario = mysql_query("SELECT * FROM usuarios WHERE Nick = '$user' AND Email = '$email'");
- if(mysql_num_rows($verificaUsuario) > 0) {
- $bool = true ;
- echo "<script>alert ('Nome de usuário ou e-mail já está cadastrado');</script>";
- }
- else {
- $bool = true ;
- mysql_query("INSERT INTO `usuarios` ( `Nick`, `Password`, `Email`) VALUES ( '$user', '$password', '$email')") or die (mysql_error());
- echo "<script>alert ('Nick registrado com Sucesso: Nick: $user Senha: $password E-mail: $email'); location.href='index.php'</script>";
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement