Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. public function insertUser(PojoUser $user) {
  2.  
  3. if ($stmt = Conn::con() != null) {
  4.  
  5. $stmt = Conn::con()->prepare('INSERT INTO usuario (email, username, password, lastaccess, active, createdat, updatedat) VALUES (:email, :username, :password, :lastaccess, :active, :createdat, :udatedat)');
  6.  
  7. $stmt->bindValue(":email", $user->getEmail(), PDO::PARAM_STR);
  8. $stmt->bindValue(":username", $user->getUsername(), PDO::PARAM_STR);
  9. $stmt->bindValue(":password", $user->getPassword(), PDO::PARAM_STR);
  10. $stmt->bindValue(":lastaccess", $user->getLastAccess(), PDO::PARAM_STR);
  11. $stmt->bindValue(":active", $user->getActive(), PDO::PARAM_INT);
  12. $stmt->bindValue(":createdat", $user->getCreatedAt(), PDO::PARAM_STR);
  13. $stmt->bindValue(":udatedat", $user->getUpdatedAt(), PDO::PARAM_STR);
  14.  
  15. $stmt->execute();
  16.  
  17. } else {
  18. echo "<p class='msg-error'> Desculpe! Erro ao estabelecer conexão. Tente novamente mais tarde.</p>";
  19. }
  20. }
  21.  
  22. <?php
  23.  
  24. private $id;
  25. private $email;
  26. private $username;
  27. private $password;
  28. private $lastAccess;
  29. private $active;
  30. private $createdAt;
  31. private $updatedAt;
  32.  
  33. public function getId() {
  34. return $this->id;
  35. }
  36.  
  37. public function setId($id) {
  38. $this->id = $id;
  39. }
  40.  
  41. public function getEmail() {
  42. return $this->email;
  43. }
  44.  
  45. public function setEmail($email) {
  46. $this->email = $email;
  47. }
  48.  
  49. public function getUsername() {
  50. return $this->username;
  51. }
  52.  
  53. public function setUsername($username) {
  54. $this->username = $username;
  55. }
  56.  
  57. public function getPassword() {
  58. return $this->password;
  59. }
  60.  
  61. public function setPassword($senha) {
  62. $this->senha = $senha;
  63. }
  64.  
  65. public function getLastAccess() {
  66. return $this->lastAccess;
  67. }
  68.  
  69. public function setLastAccess($lastAccess) {
  70. $this->lastAccess = $lastAccess;
  71. }
  72.  
  73. public function getActive() {
  74. return $this->active;
  75. }
  76.  
  77. public function setActive($active) {
  78. $this->active = $active;
  79. }
  80.  
  81. public function getCreatedAt() {
  82. return $this->createdAt;
  83. }
  84.  
  85. public function setCreatedAt($createdAt) {
  86. $this->createdAt = $createdAt;
  87. }
  88.  
  89. public function getUpdatedAt() {
  90. return $this->createdAt;
  91. }
  92.  
  93. public function setUpdatedAt($updatedAt) {
  94. $this->updatedAt = $updatedAt;
  95. }
  96.  
  97. <?php
  98.  
  99. $email = $_POST['user-email'];
  100. $password = $_POST['user-password'];
  101. $username = $_POST['user'];
  102. $conUserPassword = $_POST['conf-user-password'];
  103.  
  104. /*$re = new Register();*/
  105.  
  106. $user = new PojoUser();
  107. $userDAO = new UserDAO();
  108. $data = date('d/m/Y');
  109.  
  110.  
  111. if ($password == $conUserPassword) {
  112.  
  113. if (!($userDAO->userExists($email))) {
  114.  
  115. if ($userDAO->userNameAvaiable($username)) {
  116.  
  117. $cryptoPassword = $userDAO->crypto($password);
  118.  
  119. $user->setEmail($email);
  120. $user->setUsername($username);
  121. $user->setPassword($cryptoPassword);
  122. $user->setLastAccess($data);
  123. $user->setActive(0);
  124. $user->setCreatedAt($data);
  125. $user->setUpdatedAt($data);
  126.  
  127. $userDAO->insertUser($user);
  128.  
  129.  
  130.  
  131. //echo "<p class='msg-success'>Usuário Cadastrado com sucesso! Confirme seu email por favor.</p>";
  132.  
  133. } else {
  134. echo "<p class='msg-error'>Desculpe, este nome de usuário não está mais disponível</p>";
  135. }
  136.  
  137. } else {
  138. echo "<p class='msg-error'>Hey, parece que você já esteve por aqui, este email já está cadastrado em nosso sistema!</p>";
  139. }
  140.  
  141. } else {
  142.  
  143. echo "<p class='msg-error'>Verifique se você digitou as senhas corretamente!</p>";
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement