Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User{
- private $pdo;
- public $msg;
- public function conect($name, $host, $user, $password)
- {
- global $pdo;
- global $msg;
- try
- {
- $pdo= new PDO("mysql:dbname=".$name.";host=".$host,$user, $password);
- }
- catch (PDOException $e)
- {
- $msgError = $e->getMessage();
- }
- }
- public function register($nome, $email, $sexo, $estado_civil, $data_nascimento, $empregado_atualmente,
- $telefone, $celular, $telefone_comercial, $homepage, $nacionalidade, $cep, $endereço, $num_casa, $complemento, $bairro, $estado, $cidade)
- {
- global $pdo;
- //Verificar se o email já existe
- $sql=$pdo->prepare("SELECT id_usuario FROM dados_pessoais WHERE email = :e");
- $sql->bindValue(":e", $email);
- $sql->execute();
- if($sql->rowsCount() > 0){
- return false; //email já cadastrado
- }
- else
- {
- //caso o email estiver cadastrado todos os dados serão salvos
- $sql=$pdo->prepare("INSERT INTO dados_pessoais (nome, email, sexo, estado_civil, data_nascimento, empregado_atualmente, telefone, celular, telefone_comercial, homepage, nacionalidade, cep, endereço, num_casa, complemento, bairro, estado, cidade, senha,) VALUES (:n, :e, :sx, :ec, :dn, :ea, :tr, :cl, :tc, :hp, :na, :cp, :en, :nc, :cm, :br, :et, :ct, :se)");
- $sql->bindValue(":n", $nome);
- $sql->bindValue(":e", $email);
- $sql->bindValue(":sx", $sexo);
- $sql->bindValue(":ec", $estado_civil);
- $sql->bindValue(":dn", $data_nascimento);
- $sql->bindValue(":ea", $empregado_atualmente);
- $sql->bindValue(":tr", $telefone);
- $sql->bindValue(":cl", $celular);
- $sql->bindValue(":tc", $telefone_comercial);
- $sql->bindValue(":hp", $homepage);
- $sql->bindValue(":na", $nacionalidade);
- $sql->bindValue(":cp", $cep);
- $sql->bindValue(":en", $endereço);
- $sql->bindValue(":nc", $num_casa);
- $sql->bindValue(":cm", $complemento);
- $sql->bindValue(":br", $bairro);
- $sql->bindValue(":et", $estado);
- $sql->bindValue(":ct", $cidade);
- $sql->bindValue(":se", $senha);
- $sql->execute();
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement