Guest User

Untitled

a guest
Nov 14th, 2016
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.08 KB | None | 0 0
  1. <?php
  2.     // not really neccesary to create an account when you already have one logged in.
  3.     if(isset($_SESSION['user']))
  4.         header('Location: /');
  5.  
  6.     if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['newusername']) && isset($_POST['newname']) && isset($_POST['newemail']) && isset($_POST['newpassword']) && !isset($_SESSION['user']))
  7.     {
  8.         $password = password_hash($_POST['newpassword'], PASSWORD_DEFAULT);
  9.  
  10.         $GLOBALS['database'] -> Select ('
  11.            INSERT INTO users (login, password, name, email, accesslevel)
  12.            VALUES ($1, $2, $3, $4, $5)
  13.            ', [$_POST['newusername'], $password, $_POST['newname'], $_POST['newemail'], LEVEL_REGULAR]
  14.         );
  15.  
  16.         header('Location: /');
  17.     }
  18. ?>
  19.  
  20. <div id="createaccount">
  21.     <h1>Create an account</h1>
  22.     <br />
  23.  
  24.     <form method="post">
  25.         <p>Username:</p>
  26.         <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."/>
  27.         <br />
  28.         <p>Length must be between 3 characters and 30 characters.</p>
  29.  
  30.         <p>Name:</p>
  31.         <input type="text" name="newname" placeholder="name" autocomplete="off" value="<?php $newname; ?>" required />
  32.         <br />
  33.         <p>This will be displayed as your default name over the website.</p>
  34.  
  35.         <p>Email address:                    </p>
  36.         <input type="email" name="newemail" placeholder="email" autocomplete="off" value="<?php $newemail; ?>" required />
  37.         <br />
  38.         <p>Alternate login. Not specifically used yet.</p>
  39.  
  40.         <p>Password:</p>
  41.         <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."/>
  42.         <br />
  43.         <p>Must be between 6 characters and 30 characters.</p>
  44.  
  45.         <hr>
  46.  
  47.         <input type="reset" value="Reset">
  48.         <input type="submit" value="Create">
  49.     </form>
  50. </div>
Add Comment
Please, Sign In to add comment