Advertisement
Guest User

Untitled

a guest
Mar 15th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="PT-BR">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Login</title>
  6. </head>
  7. <body>
  8. <form action="../../controllers/UserController.php" method="post" name="formLogin">
  9. <label>E-mail</label>
  10. <div class="email">
  11. <input type="text" name="user[email]" required>
  12. </div>
  13.  
  14. <!--INSERIR A CONFIRMAÇÃO DE E-MAIL-->
  15.  
  16. <label>Password</label>
  17. <div class="password">
  18. <input type="password" name="user[password]" required>
  19. </div>
  20. <!--INSERIR A CONFIRMAÇÃO DE SENHA-->
  21.  
  22. <label>Nível de Acesso</label>
  23. <div class="">
  24. <label>
  25. <input type="radio" name="user[level]" value="1">
  26. Gerente
  27. </label>
  28. <label>
  29. <input type="radio" name="user[level]" value="2">
  30. Membro
  31. </label>
  32. </div>
  33.  
  34. <div>
  35. <label>
  36. <input type="radio" name="user[type]" value="1">
  37. Nível 1
  38. </label>
  39. <label>
  40. <input type="radio" name="user[type]" value="2">
  41. Nível 2
  42. </label>
  43. </div>
  44.  
  45. <input type="hidden" name="action" value="insert">
  46.  
  47. <div class="submit">
  48. <input type="submit" name="submit">
  49. </div>
  50.  
  51. </body>
  52. </html>
  53.  
  54. <?php
  55. require_once(__DIR__."../../helpers/Connection.php");
  56.  
  57. class User {
  58. public $id;
  59. public $email;
  60. public $password;
  61. public $level;
  62. public $type;
  63.  
  64. public function __construct($attributes) {
  65. $this->id = isset($attributes['id']) ? $attributes['id'] : null;
  66. $this->email = $attributes['email'];
  67. $this->password = $attributes['password'];
  68. $this->level = $attributes['level'];
  69. $this->type = $attributes['type'];
  70. }
  71.  
  72. public function insert(){
  73. $connect = Connection::connect();
  74. $stm = $connect->prepare("INSERT INTO user(email, password, level, type) VALUES (':email', ':password', ':level', ':type')");
  75. $stm = bindValue(":email", $this->email, PDO::PARAM_STR);
  76. $stm = bindValue(":password", $this->password, PDO::PARAM_STR);
  77. $stm = bindValue(":level", $this->level, PDO::PARAM_INT);
  78. $stm = bindValue(":type", $this->type, PDO::PARAM_INT);
  79. return $stm->execute();
  80.  
  81. }
  82. }
  83. ?>
  84.  
  85. <?php
  86. require_once("../models/Users.php");
  87. /**
  88. *
  89. */
  90. class UserController {
  91.  
  92. public static function insert(){
  93. $user = new User($_POST["user"]);
  94. $user->insert();
  95.  
  96. }
  97. }
  98.  
  99. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement