Guest User

Untitled

a guest
Feb 18th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include realpath("./inc/class.template.php");
  4. include realpath("./inc/config.php");
  5. $template->_get("header.html");
  6. $template->_set(array(
  7. 'TZ_TITLE' => 'Tezzy',
  8. 'BB_SUBT' => 'Index',
  9. 'BB_USER' => 'Username'
  10. ));
  11.  
  12. if(isset($_POST['submitR'])) {
  13.  
  14. $username = $_POST['username'];
  15. $password = $_POST['password'];
  16. $passwordC = $_POST['passwordC'];
  17. $email = $_POST['email'];
  18. $ipaddress = $_SERVER['REMOTE_ADDR'];
  19. $session = session_id();
  20.  
  21. if($username == '' | $password == '' | $passwordC == '' | $email == '') {
  22. header("Location: ./register.php?error=1"); // Tells to fill in all fields
  23. } elseif ($password != $passwordC) {
  24. header("Location: ./register.php?error=2"); // Checks to see if password is correct
  25. } elseif (mysql_num_rows(mysql_query("SELECT * from users WHERE username='" . $_POST['username'] . "'")) == 1) {
  26. header("Location: ./register.php?error=3"); // Checks to see if username is taken
  27. } elseif (mysql_num_rows(mysql_query("SELECT * from users WHERE email='" . $_POST['email'] . "'")) == 1) {
  28. header("Location: ./register.php?error=4"); // Checks to see if email is taken
  29. } else {
  30. function sha512($str) { return hash("sha512", $str); }
  31. $password = sha512($password);
  32. mysql_query("INSERT INTO users (username,password,email,ip, session) VALUES ('{$username}','{$password}','{$email}','{$ipaddress}','{$session}')");
  33. header("Location: ./register.php?success=1");
  34. }
  35. }
  36.  
  37. $template->_get("register_body.html");
  38. $template->_set(array(
  39. 'TZ_TITLE' => 'Tezzy'
  40. ));
  41.  
  42. $template->_get("footer.html");
  43. $template->_set(array(
  44. 'BB_TITLE' => 'Tezzy'
  45. ));
  46. ?>
Add Comment
Please, Sign In to add comment