Guest User

register.php

a guest
Jun 13th, 2017
95
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. require_once('db.config.php');
  3. $user_ip = $_SERVER['REMOTE_ADDR'];
  4. $username = isset($_POST['username']) ? trim($_POST['username']) : '';
  5. $password = isset($_POST['password']) ? trim($_POST['password']) : '';
  6. $password2 = isset($_POST['password2']) ? trim($_POST['password2']) : '';
  7. $nombre = isset($_POST['nombre']) ? trim($_POST['nombre']) : '';
  8. $apellidos = isset($_POST['apellidos']) ? trim($_POST['apellidos']) : '';
  9. $email = isset($_POST['email']) ? trim($_POST['email']) : '';
  10. $patron = isset($_POST['patron']) ? trim($_POST['patron']) : '';
  11. $errors = array();
  12. $success = false;
  13. if(isset($_POST) && !empty($_POST)){
  14. if(empty($username)){
  15. $errors[] = 'Please provide a user name.';
  16. }else if(strlen($username) < 3 || strlen($username) > 16){
  17. $errors[] = 'User name must be between 3 and 16 characters in length.';
  18. }else if(ctype_alnum($username) === false){
  19. $errors[] = 'User name must consist of numbers and letters only.';
  20. }else{
  21. // Check if username already exists in the database.
  22. $sql = "SELECT UserID FROM PS_UserData.dbo.Users_Master WHERE UserID = ?";
  23. $stmt = odbc_prepare($GLOBALS['dbConn'],$sql);
  24. $args = array($username);
  25. if(!odbc_execute($stmt,$args)){
  26. $errors[] = 'Failed to determine if this username already exists in the database.';
  27. }elseif($row = odbc_fetch_array($stmt)){
  28. $errors[] = 'User name already exists, please choose a different user name.';
  29. }
  30. }
  31. if(empty($password)){
  32. $errors[] = 'Please provide a password.';
  33. }else if(strlen($password) < 3 || strlen($password) > 16){
  34. $errors[] = 'Password must be between 3 and 16 characters in length.';
  35. }else if($password != $password2){
  36. $errors[] = 'Passwords do not match.';
  37. }
  38. if(count($errors) == 0){
  39. $sql = "INSERT INTO PS_UserData.dbo.Users_Master
  40. (UserID,Pw,JoinDate,Admin,AdminLevel,UseQueue,Status,Leave,LeaveDate,UserType,Point,EnPassword,UserIp,nombre,apellidos,email,patron)
  41. VALUES (?,?,GETDATE(),0,0,0,0,0,GETDATE(),'N',0,'',?,?,?,?,?)";
  42. $stmt = odbc_prepare($GLOBALS['dbConn'],$sql);
  43. $args = array($username,$password,$user_ip,$nombre,$apellidos,$email,$patron);
  44. if(odbc_execute($stmt,$args)){
  45. $success = htmlentities("Account {$username} successfully created!");
  46. }else{
  47. $errors[] = 'Failed to create a new account, please try again later';
  48. }
  49. }
  50. }
  51. if($success === false){
  52. require_once('register.view.php');
  53. }else{
  54. require_once('success.view.php');
  55. }
  56. ?>
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×