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()
- {
- return "auth/register";
- }
- public function login()
- {
- return "auth/login";
- }
- 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= $user->token = bin2hex(openssl_random_pseudo_bytes(16));
- $this->getStorage()->store($user);
- if ($_POST['id'])
- {
- header("location: /auth/confirmation_notice");
- }
- else if(!$_POST['id'])
- {
- header("location: /auth/register");
- exit;
- }
- }
- }
- <h2 class="register">Register</h2>
- <?php
- use Model\User;
- use Storage\MySQLStorage;
- $id = $name = $surname = $email = $password = $password_confirmation = "";
- // $token = "32";
- ?>
- <form method="post" action="/auth/store">
- <input type="number" name="id"> Id<br>
- <input type="text" name="name"> Name<br>
- <input type="text" name="surname"> Surname<br>
- <input type="text" name="email"> Email<br>
- <input type="text" name="password"> Password<br>
- <input type="text" name="password_confirmation"> Password Confirmation<br>
- <input type="text" name="token"> Token<br>
- <input type="submit" name="Create" value="Create"><br>
- </form>
- <?php
- echo '<li class="error">The id filed cannot be empty</li>';
- echo '<li class="error">The name filed cannot be empty</li>';
- echo '<li class="error">The id filed cannot be empty</li>';
- echo '<li class="error">The surname filed cannot be empty</li>';
- echo '<li class="error">The email filed cannot be empty</li>';
- echo '<li class="error">The password filed cannot be empty</li>';
- echo '<li class="error">The password confirmation filed cannot be empty</li>';
- echo '<li class="error">The password confirmation filed does not match the password field</li>';
- echo '<li class="error">The password filed cannot be empty</li>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement