Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. class User{
  2.  
  3. private $pdo;
  4. public $msg;
  5.  
  6. public function conect($name, $host, $user, $password)
  7. {
  8. global $pdo;
  9. global $msg;
  10.  
  11. try
  12. {
  13. $pdo= new PDO("mysql:dbname=".$name.";host=".$host,$user, $password);
  14. }
  15. catch (PDOException $e)
  16. {
  17. $msgError = $e->getMessage();
  18. }
  19.  
  20.  
  21. }
  22.  
  23. public function register($nome, $email, $sexo, $estado_civil, $data_nascimento, $empregado_atualmente,
  24. $telefone, $celular, $telefone_comercial, $homepage, $nacionalidade, $cep, $endereço, $num_casa, $complemento, $bairro, $estado, $cidade)
  25. {
  26. global $pdo;
  27.  
  28. //Verificar se o email já existe
  29. $sql=$pdo->prepare("SELECT id_usuario FROM dados_pessoais WHERE email = :e");
  30. $sql->bindValue(":e", $email);
  31. $sql->execute();
  32.  
  33. if($sql->rowsCount() > 0){
  34. return false; //email já cadastrado
  35. }
  36. else
  37. {
  38. //caso o email estiver cadastrado todos os dados serão salvos
  39. $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)");
  40. $sql->bindValue(":n", $nome);
  41. $sql->bindValue(":e", $email);
  42. $sql->bindValue(":sx", $sexo);
  43. $sql->bindValue(":ec", $estado_civil);
  44. $sql->bindValue(":dn", $data_nascimento);
  45. $sql->bindValue(":ea", $empregado_atualmente);
  46. $sql->bindValue(":tr", $telefone);
  47. $sql->bindValue(":cl", $celular);
  48. $sql->bindValue(":tc", $telefone_comercial);
  49. $sql->bindValue(":hp", $homepage);
  50. $sql->bindValue(":na", $nacionalidade);
  51. $sql->bindValue(":cp", $cep);
  52. $sql->bindValue(":en", $endereço);
  53. $sql->bindValue(":nc", $num_casa);
  54. $sql->bindValue(":cm", $complemento);
  55. $sql->bindValue(":br", $bairro);
  56. $sql->bindValue(":et", $estado);
  57. $sql->bindValue(":ct", $cidade);
  58. $sql->bindValue(":se", $senha);
  59. $sql->execute();
  60. return true;
  61.  
  62. }
  63. }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement