Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once "core/init.php";
- if (Input::exists()) {
- if (Token::check(Input::get('token'))) {
- $validate = new Validate();
- $validation = $validate->check($_POST, array(
- 'username' => array(
- 'required' => true,
- 'min' => 2,
- 'max' => 20,
- 'unique' => 'users'
- ),
- 'password' => array(
- 'required' => true,
- 'min' => 6
- ),
- 'password-confirm' => array(
- 'required' => true,
- 'matches' => 'password'
- )
- ));
- if ($validation->passed()) {
- $user = new User();
- $salt = Hash::salt(32);
- try {
- $user->create(array(
- 'username' => Input::get('username'),
- 'password' => Hash::make(Input::get('password'), $salt),
- 'salt' => $salt,
- 'joined' => date('Y-m-d H:i:s'),
- 'group' => 1
- ));
- Session::flash('home', 'You have succesfully been registered and can now log in!');
- Redirect::to('index.php');
- } catch (Exception $e) {
- die($e->getMessage());
- }
- } else {
- foreach($validation->errors() as $error) {
- echo $error, '<br>';
- }
- }
- }
- }
- ?>
- <form action="" method="POST">
- <div class="field">
- <label for="username">Username</label>
- <input type="text" name="username" id="username" value="<?php echo escape(Input::get('username')); ?>" autcomplete="off">
- </div>
- <div class="field">
- <label for="password">Password</label>
- <input type="password" name="password" id="password">
- </div>
- <div class="field">
- <label for="password-confirm">Confirm Password</label>
- <input type="password" name="password-confirm" id="password-confirm">
- </div>
- <input type="hidden" name="token" value="<?php echo Token::generate(); ?>">
- <input type="submit" value="Register">
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement