Teknik is a suite of services with attractive and functional interfaces. https://www.teknik.io/
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

process_registration.php 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. require_once('config.php');
  3. //initialize php variables used in the form
  4. $username = "";
  5. $password = "";
  6. $password_confirm = "";
  7. $error = "";
  8. //check to see that the form has been submitted
  9. if(isset($_POST))
  10. {
  11. //retrieve the $_POST variables
  12. $username = rawurldecode($_POST['username']);
  13. $password = rawurldecode($_POST['password']);
  14. $password_confirm = rawurldecode($_POST['password_confirm']);
  15. if (!$CONF['dev_env'])
  16. {
  17. $obBaseApp = new COM("hMailServer.Application");
  18. $obBaseApp->Connect();
  19. $obBaseApp->Authenticate($CONF['mail_admin_user'], $CONF['mail_admin_pass']);
  20. $domain = $obBaseApp->Domains->ItemByName($CONF['host']);
  21. }
  22. //initialize variables for form validation
  23. $success = true;
  24. if($success && safe_register($username) != $username)
  25. {
  26. $error = "Invalid Characters in username.";
  27. $success = false;
  28. }
  29. $username = safe_register($username);
  30. if($success && !$username)
  31. {
  32. $error = "You must input a Username.";
  33. $success = false;
  34. }
  35. //validate that the form was filled out correctly
  36. //check to see if user name already exists
  37. if($success && $userTools->checkUsernameExists($username))
  38. {
  39. $error = "That username is already taken.";
  40. $success = false;
  41. }
  42. if (!$CONF['dev_env'])
  43. {
  44. if($success && $userTools->checkEmailExists($domain, $username . "@" . $CONF['host']))
  45. {
  46. $error = "The email for that username is already taken.";
  47. $success = false;
  48. }
  49. }
  50. if($success && !$password)
  51. {
  52. $error = "You must input a Password.";
  53. $success = false;
  54. }
  55. //check to see if passwords match
  56. if($success && $password != $password_confirm)
  57. {
  58. $error = "Passwords do not match.";
  59. $success = false;
  60. }
  61. if($success)
  62. {
  63. $email = $username . "@" . $CONF['host'];
  64. //prep the data for saving in a new user object
  65. $data['username'] = $username;
  66. $data['password'] = hashPassword($password, $CONF); //encrypt the password for storage
  67. //create the new user object
  68. $newUser = new User($data, $db);
  69. //save the new user to the database
  70. $newUser->save($db, true);
  71. if (!$CONF['dev_env'])
  72. {
  73. //Create an email for the user
  74. $account = $domain->Accounts->Add();
  75. $account->Address = $email;
  76. $account->Password = $password;
  77. $account->Active = True;
  78. $account->MaxSize = 1000;
  79. $account->Save();
  80. }
  81. //log them in
  82. $userTools->login($username, hashPassword($password, $CONF), false, $CONF);
  83. //redirect them to a welcome page
  84. echo "true";
  85. }
  86. else
  87. {
  88. echo $error;
  89. }
  90. }
  91. else
  92. {
  93. echo "$_POST is not set.";
  94. }
  95. ?>