Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <?php
  2.  
  3. include 'mysqlHandler.php';
  4.  
  5. openConnection();
  6.  
  7. $u = str_replace(" ", "", $_POST['username']);
  8. $u = mysql_real_escape_string($u);
  9.  
  10. $p = $_POST['password'];
  11.  
  12. if (strlen($p) < 6) {
  13.     header("Location:createAccount.php?bad_password=1");
  14. } else if ($_POST['password'] != $_POST['password2']) {
  15.     header("Location:createAccount.php?bad_password=1");
  16. } else if (empty($u)) {
  17.     header("Location:createAccount.php?user_exists=1");
  18. } else {
  19.     $p = hashPassword($_POST['password']);
  20.     $result = executeQuery("insert into user (username, password) values ('" . $u . "', '" . $p . "')");
  21.  
  22.     if ($result) {
  23.         include 't/headSectionUnclosed.php';
  24.         echo '</head><body>';
  25.         include 't/userBar.php';
  26.         echo '<h1>Successfully created account</h1>';
  27.         echo '<h2>Welcome aboard, <em>' .$u . '!</em></h2>';
  28.         echo '<a href="index.php" id="button-link">Log in &rarr;</a>';
  29.         echo '</body></html>';
  30.     } else {
  31.         header("Location:createAccount.php?user_exists=1");
  32.     }
  33. }
  34.  
  35. closeConnection();
  36. ?>