Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="PT-BR">
- <head>
- <meta charset="utf-8">
- <title>Login</title>
- </head>
- <body>
- <form action="../../controllers/UserController.php" method="post" name="formLogin">
- <label>E-mail</label>
- <div class="email">
- <input type="text" name="user[email]" required>
- </div>
- <!--INSERIR A CONFIRMAÇÃO DE E-MAIL-->
- <label>Password</label>
- <div class="password">
- <input type="password" name="user[password]" required>
- </div>
- <!--INSERIR A CONFIRMAÇÃO DE SENHA-->
- <label>Nível de Acesso</label>
- <div class="">
- <label>
- <input type="radio" name="user[level]" value="1">
- Gerente
- </label>
- <label>
- <input type="radio" name="user[level]" value="2">
- Membro
- </label>
- </div>
- <div>
- <label>
- <input type="radio" name="user[type]" value="1">
- Nível 1
- </label>
- <label>
- <input type="radio" name="user[type]" value="2">
- Nível 2
- </label>
- </div>
- <input type="hidden" name="action" value="insert">
- <div class="submit">
- <input type="submit" name="submit">
- </div>
- </body>
- </html>
- <?php
- require_once(__DIR__."../../helpers/Connection.php");
- class User {
- public $id;
- public $email;
- public $password;
- public $level;
- public $type;
- public function __construct($attributes) {
- $this->id = isset($attributes['id']) ? $attributes['id'] : null;
- $this->email = $attributes['email'];
- $this->password = $attributes['password'];
- $this->level = $attributes['level'];
- $this->type = $attributes['type'];
- }
- public function insert(){
- $connect = Connection::connect();
- $stm = $connect->prepare("INSERT INTO user(email, password, level, type) VALUES (':email', ':password', ':level', ':type')");
- $stm = bindValue(":email", $this->email, PDO::PARAM_STR);
- $stm = bindValue(":password", $this->password, PDO::PARAM_STR);
- $stm = bindValue(":level", $this->level, PDO::PARAM_INT);
- $stm = bindValue(":type", $this->type, PDO::PARAM_INT);
- return $stm->execute();
- }
- }
- ?>
- <?php
- require_once("../models/Users.php");
- /**
- *
- */
- class UserController {
- public static function insert(){
- $user = new User($_POST["user"]);
- $user->insert();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement