Jump to content
  • 0

Do not allow to create account with the same user


Scofield

Question


  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.03
  • Content Count:  265
  • Reputation:   11
  • Joined:  01/11/13
  • Last Seen:  

I want you not to be allowed to create an account with the same use

<?php
error_reporting(0);
include('connect.php');

$usuario =  $_POST['user'];
$senha =  $_POST['pass'];
$senha2 =  $_POST['conf'];
$gen = $_POST['genero'];
$email = $_POST['mail'];

if (isset($senha)){

//Verifica se já existe um email no banco de dados
$cons = "SELECT email FROM login WHERE email='".$email."'";
$sql =  mysql_query($cons);
$res = mysql_fetch_array($sql);
$verifica = $res['email'];


if($veririca != ""){  // condição. se existir um email ja cadastrado, não pode proceguir
echo "<script>alert('Desculpe mais me parece que este e-mail ja esta em uso!')</script>";
}else{

if($senha != $senha2){   // Confirmação de senha (validação)
echo "<script>alert('Desculpe mais me parece que suas senhas estao incorretas!')</script>";
}else{

//Procedimento de cadastro
$cad = "INSERT INTO login (userid,user_pass,sex,email) VALUES ('".$usuario."','".$senha."','".$gen."','".$email."')";
$c_cad = mysql_query($cad);
if ($cad) {
echo "<script>alert('Cadastro efetuado com sucesso!')</script>";
#echo "<meta http-equiv=\"refresh\" content=\"1; url:index.php\" />";
}

}
}

}else{
#echo "<p style=\"color: #E40D6B; font-size: 12px; font-family: verdana,arial; font-weight: bold; text-align: center;\";>Preencha seus dados!</p>";
}

?>

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  44
  • Topics Per Day:  0.01
  • Content Count:  898
  • Reputation:   119
  • Joined:  05/23/12
  • Last Seen:  

Please read some informations about security vulnerabilities like Cross-Side scripting and SQL-Injection. MySQL is deprecated please use MySQLi instead.

You'll need some server side checks! Example: preg_replace()

 

Rynbef~

Link to comment
Share on other sites

×
×
  • Create New...