Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Controller;
- use Model\User;
- class AuthController extends Controller
- {
- public function register()
- {
- if(isset($_POST["submit"]))
- {
- if($_POST["id"]=='')
- echo '<li class="error">The id filed cannot be empty</li>';
- if($_POST["name"]=='')
- echo '<li class="error">The name filed cannot be empty</li>';
- if($_POST["surname"]=='')
- echo '<li class="error">The surname filed cannot be empty</li>';
- if($_POST["password"]=='')
- echo '<li class="error">The email filed cannot be empty</li>';
- if($_POST["password"]=='')
- echo '<li class="error">The password filed cannot be empty</li>';
- if($_POST["password_confirmation"]=='')
- echo '<li class="error">The password confirmation filed cannot be empty</li>';
- if($_POST["id"]!='' && $_POST["name"]!='' && $_POST["surname"]!='' && $_POST["email"]!='' && $_POST["password"]!='' && $_POST["password_confirmation"]!='')
- {
- $this->store();
- }
- else
- return "auth/register";
- }
- else
- return "auth/register";
- }
- public function confirmation_notice()
- {
- return "auth/confirmation_notice";
- }
- public function store()
- {
- $user = new User($_POST["id"]);
- $user->name = $_POST["name"];
- $user->surname = $_POST["surname"];
- $user->email = $_POST["email"];
- $user->password = password_hash($_POST["password"],PASSWORD_BCRYPT);
- $user->password_confirmation = $_POST["password_confirmation"];
- $user->token = bin2hex(openssl_random_pseudo_bytes(16));
- $this->getStorage()->store($user);
- header("location: /auth/confirmation_notice");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement