Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once "init/init.php";
- $error = null;
- if(array_key_exists("username", $_POST)
- && array_key_exists("password1", $_POST)
- && array_key_exists("password2", $_POST))
- {
- try
- {
- if(mb_strlen($_POST["username"]) < 3)
- throw new Exception("Username must contain at least 3 characters.");
- if($_POST["password1"] != $_POST["password2"])
- throw new Exception("Passwords don't match.");
- if(mb_strlen($_POST["password1"]) < 6)
- throw new Exception("Password must contain at least 6 characters.");
- $user = $web->createUser();
- $user->username = $_POST["username"];
- $user->password = $_POST["password1"];
- header(sprintf("Location: %suser.php?id=%d", BASEURL, $user->id));
- }
- catch(Exception $e)
- {
- $error = $e->getMessage();
- }
- }
- include "inc/output.php";
- ?>
- <h1>Register an account</h1>
- <?if($error):?>
- <h2>Error: <?=html($error)?></h2>
- <?endif?>
- <form method=post action=<?=htmlparam(REQUEST)?>>
- <label for=username>Username</label>
- <input id=username name=username maxlength=16
- value=<?=htmlparam(ifset($_POST['username']))?>>
- <br>
- <label for=password1>Password</label>
- <input id=password1 type=password name=password1>
- <br>
- <label for=password2>Password (repeat)</label>
- <input id=password2 type=password name=password2>
- <br>
- <button type=submit>Register</button>
- </form>
- <?include "inc/output.php"?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement