public function registerAction() { $Auth = new Auth(); $post = $this->request->getPost(); if (isset($post['username'])) { $Auth->register($post); header('Location:' . Url::getUrl('user', 'login')); } }
<?php /** * Amber * @package principal * @author César Martins * @version 1.0 */ include "bibliotecas/php/class.Auth.php"; $auth = new Auth(); $auth->logout(); $auth->register("terezacampos", "a!@#b!@#CD13", "a!@#b!@#CD13", "*****@*****.**"); $auth->logout(); $auth->register("eronildo", "a!@#b!@#CD14", "a!@#b!@#CD14", "*****@*****.**"); $auth->logout(); $auth->register("onicio", "a!@#b!@#CD15", "a!@#b!@#CD15", "*****@*****.**"); $auth->logout(); $auth->register("lucilene", "a!@#b!@#CD16", "a!@#b!@#CD16", "*****@*****.**"); $auth->logout(); $auth->register("dennis", "a!@#b!@#CD17", "a!@#b!@#CD17", "*****@*****.**"); $auth->logout(); $auth->register("cesar", "a!@#b!@#CD18", "a!@#b!@#CD18", "*****@*****.**"); $auth->logout(); //Para validar o usuário é preciso alterar na tabela users os campos isactive para 1, e activekey para 0 print_r($auth);
<?php if (isset($_POST["username"])) { @session_start(); include "../php/class.Auth.php"; $auth = new Auth(); if ($auth->register($_POST["username"], $_POST["password"], $_POST["re-password"], $_POST["email"])) { $_SESSION["errormsg"] = "Cadastro realizado com sucesso!"; } else { $_SESSION["errormsg"] = $auth->errormsg; } } header("Location: cad_user.php"); ?>
<?php // CONTROLLER, MODEL 불러오기 include '../Class/Auth.php'; // 회원가입 $auth = new Auth(); $auth->register($_POST['name'], $_POST['password'], $_POST['re_password'], $_POST['phone'], $_POST['email']);
<?php include_once "db_class.php"; include_once "login_class.php"; if (isset($_POST["submit"])) { $auth = new Auth(); $auth->register($_POST["email"], $_POST["password"], $_POST["password_confirm"]); } ?> <form action="<?php echo $_SERVER["PHP_SELF"]; ?> " method="post"> <table border="0"> <tr> <td>Email:</td> <td><input type="text" name="email" maxlength="60"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" maxlength="10"></td> </tr> <tr> <td>Confirm Password:</td> <td><input type="password" name="password_confirm" maxlength="10"></td> </tr> <tr> <th colspan=2><input type="submit" name="submit" value="Register"></th> </tr> </table>
switch ($page) { case 'main': require 'main.php'; break; case 'register': require 'register.php'; break; case 'login': require 'login.php'; break; case 'user_panel': require 'user_panel.php'; break; case 'register_action': $register = new Auth($pdo); $result = $register->register(['login' => $_POST['login'], 'password' => $_POST['password'], 'email' => $_POST['email']]); echo is_array($result) && $result[1] == true ? $result[0] : $result; break; case 'login_action': $login = new Auth($pdo, $session); $result = $login->login(['login' => $_POST['login'], 'password' => $_POST['password']]); if (is_array($result) && $result[1] == true) { echo $result[0]; header("Refresh:2;URL=?page=user_panel"); } else { echo $result; } break; case 'logout': $login = new Auth($pdo); $login->logout();
<?php $error = false; if (isset($_POST['username'])) { $username = $_POST['username']; $password = $_POST['password']; $password2 = $_POST['password2']; if (!$username) { $error = "Username cannot be empty"; } elseif (!$password) { $error = "Password cannot be empty"; } elseif ($password != $password2) { $error = "Passwords must match"; } elseif (!Auth::register($username, $password)) { $error = "User can not be registered"; } else { Auth::login($username, $password); Router::redirect("admin"); } }
header('Location: /'); exit; } } } // if 'Register' is clicked if (isset($_POST['register'])) { $name = trim($_POST['name']); $username = trim($_POST['username']); $password = trim($_POST['password']); // validate input if (V::notEmpty($name) && V::isAlpha($name) && V::maxLength($name, 20) && V::notEmpty($username) && V::isUsername($username) && V::maxLength($username, 20) && V::notEmpty($password) && V::maxLength($password, 20)) { // if input ok register user and force login $user = new User($name, $username, $password); $auth = new Auth($db, $user); $password = $auth->register(); /*echo '<pre>'; var_dump($auth); echo '</pre>';exit;*/ $auth->forceLogin($password); header('Location: /'); exit; } else { $message = 'Correct your input and try again.'; buildView('auth/register', compact('message')); exit; } } // if 'Or register' is clicked if (isset($_GET['register'])) { buildView('auth/register');
<?php /** * Amber * @package principal * @author César Martins * @version 1.0 */ include "bibliotecas/php/class.Auth.php"; $auth = new Auth(); $auth->logout(); $auth->register("saudepegovbr01", "a!@#b!@#CD01", "a!@#b!@#CD01", "*****@*****.**"); $auth->logout(); $auth->register("saudepegovbr02", "a!@#b!@#CD02", "a!@#b!@#CD02", "*****@*****.**"); $auth->logout(); $auth->register("saudepegovbr03", "a!@#b!@#CD03", "a!@#b!@#CD03", "*****@*****.**"); $auth->logout(); $auth->register("saudepegovbr04", "a!@#b!@#CD04", "a!@#b!@#CD04", "*****@*****.**"); $auth->logout(); $auth->register("saudepegovbr05", "a!@#b!@#CD05", "a!@#b!@#CD05", "*****@*****.**"); $auth->logout(); $auth->register("saudepegovbr06", "a!@#b!@#CD06", "a!@#b!@#CD06", "*****@*****.**"); $auth->logout(); $auth->register("saudepegovbr07", "a!@#b!@#CD07", "a!@#b!@#CD07", "*****@*****.**"); $auth->logout(); $auth->register("saudepegovbr08", "a!@#b!@#CD08", "a!@#b!@#CD08", "*****@*****.**"); $auth->logout(); $auth->register("saudepegovbr09", "a!@#b!@#CD09", "a!@#b!@#CD09", "*****@*****.**"); $auth->logout(); $auth->register("saudepegovbr10", "a!@#b!@#CD10", "a!@#b!@#CD10", "*****@*****.**"); $auth->logout();