Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // not really neccesary to create an account when you already have one logged in.
- if(isset($_SESSION['user']))
- header('Location: /');
- if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['newusername']) && isset($_POST['newname']) && isset($_POST['newemail']) && isset($_POST['newpassword']) && !isset($_SESSION['user']))
- {
- $password = password_hash($_POST['newpassword'], PASSWORD_DEFAULT);
- $GLOBALS['database'] -> Select ('
- INSERT INTO users (login, password, name, email, accesslevel)
- VALUES ($1, $2, $3, $4, $5)
- ', [$_POST['newusername'], $password, $_POST['newname'], $_POST['newemail'], LEVEL_REGULAR]
- );
- header('Location: /');
- }
- ?>
- <div id="createaccount">
- <h1>Create an account</h1>
- <br />
- <form method="post">
- <p>Username:</p>
- <input type="text" name="newusername" placeholder="username" autocomplete="off" value="<?php $newusername; ?>" pattern=".{3, 30}" required title="Length must be between 3 characters and 30 characters."/>
- <br />
- <p>Length must be between 3 characters and 30 characters.</p>
- <p>Name:</p>
- <input type="text" name="newname" placeholder="name" autocomplete="off" value="<?php $newname; ?>" required />
- <br />
- <p>This will be displayed as your default name over the website.</p>
- <p>Email address: </p>
- <input type="email" name="newemail" placeholder="email" autocomplete="off" value="<?php $newemail; ?>" required />
- <br />
- <p>Alternate login. Not specifically used yet.</p>
- <p>Password:</p>
- <input type="password" name="newpassword" placeholder="password" autocomplete="off" value="<?php $newpassword; ?>" pattern=".{6,30}" required title="Must be between 6 characters and 30 characters."/>
- <br />
- <p>Must be between 6 characters and 30 characters.</p>
- <hr>
- <input type="reset" value="Reset">
- <input type="submit" value="Create">
- </form>
- </div>
Add Comment
Please, Sign In to add comment