Advertisement
Guest User

Untitled

a guest
Oct 6th, 2017
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.73 KB | None | 0 0
  1. <?php
  2. use phpformbuilder\Form;
  3. use phpformbuilder\Validator\Validator;
  4. use phpformbuilder\database\Mysql;
  5. // add this line for debugging
  6. ini_set('display_errors', 1);
  7. // ----
  8.  
  9.  
  10.  
  11. /* =============================================
  12. start session and include form class
  13. ============================================= */
  14.  
  15. session_start();
  16. include_once rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/xy/dev/assets/mform/Form.php';
  17.  
  18. /* =============================================
  19. validation if posted
  20. ============================================= */
  21.  
  22. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  23. if(Form::testToken('m-sign-up-modal-form-1') === true) {
  24.  
  25. // create validator & auto-validate required fields
  26. $validator = Form::validate('m-sign-up-modal-form-1');
  27.  
  28. // additional validation
  29. $validator->hasLowercase()->hasUppercase()->hasNumber()->hasSymbol()->minLength(8)->validate('user-password');
  30. $validator->email()->validate('user-email');
  31. // // // $validator->maxLength(100)->validate('message');
  32. // recaptcha validation
  33. $validator->recaptcha('xyz', 'Recaptcha Error')->validate('g-recaptcha-response');
  34. // check for errors
  35.  
  36. if ($validator->hasErrors()) {
  37. $_SESSION['errors']['m-sign-up-modal-form-1'] = $validator->getAllErrors();
  38. $msg = '<p class="alert alert-danger">' . $validator->getAllErrors() . '</p>' . " \n";
  39. exit();
  40. } else {
  41.  
  42. require_once rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/xy/dev/assets/mform/database/db-connect.php';
  43. require_once rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/xy/dev/assets/mform/database/Mysql.php';
  44.  
  45. $db = new Mysql();
  46. $insert['ID'] = Mysql::SQLValue('');
  47. $insert['user-name'] = Mysql::SQLValue($_POST['user-name']);
  48. $insert['user-email'] = Mysql::SQLValue($_POST['user-email']);
  49. $insert['user-password'] = Mysql::SQLValue($_POST['user-password']);
  50.  
  51. if (!$db->insertRow('avia_signUps', $insert)) {
  52. $msg = '<p class="alert alert-danger">' . $db->error() . '<br>' . $db->getLastSql() . '</p>' . " \n";
  53. exit();
  54. } else {
  55. $msg = '<p class="alert alert-success">Thank you for enrolling the AVIAUCTION registration. Please check your eMail to proceed. Best regards</p><br />AVIAUCTION TEAM' . " \n";
  56.  
  57. $smtp_settings = array(
  58. // MAIL GOES TO FORM_USER
  59. require rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/mform/mail2admin.php',
  60.  
  61. 'Host' => 'send.smtp.com',
  62. 'SMTPAuth' => true,
  63. //'smtp_auth' => true,
  64. 'Username' => 'no_reply@email.com',
  65. 'Password' => 'passw0rd',
  66. 'SMTPSecure' => 'tls',
  67. 'Port' => '587', //smtp.gmail.com uses port 465
  68. 'IsHTML' => true,
  69. ClearAddresses(),
  70. ClearReplyTos(),
  71. 'From' => 'no_reply@email.com',
  72. 'FromName' => 'the name',
  73. //'sender_name' => 'the name',
  74. 'Charset' => 'UTF-8',
  75. 'Encoding' => 'base64',
  76. 'ContentType' => 'text/html',
  77.  
  78. 'recipient_email' => addslashes($_POST['user-email']),
  79. 'addBCC' => 'bcc@email.com',
  80. 'subject' => 'the subject',
  81. 'filter_values' => 'm-sign-up-modal-form-1, captcha, submit-btn, token',
  82. 'Body' => $auto_response,
  83. 'AltBody' => 'Use another another email client',
  84.  
  85. 'SMTPDebug' => '2',
  86. 'Debugoutput' => 'html'
  87. );
  88.  
  89. // $sent_message = Form::sendMail($smtp_settings);
  90.  
  91. if(!$sent_message = Form::sendMail($smtp_settings)){
  92. $msg = '<p class="alert alert-danger">mailforu:' . $smtp_settings->error() . '</p>' . " \n";
  93. exit();
  94. }
  95. else {
  96.  
  97. $smtp_settings = array(
  98. // MAIL GOES TO ADMIN
  99. require rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/mform/mail2admin.php',
  100.  
  101. 'Host' => 'send.smtp.com',
  102. 'SMTPAuth' => true,
  103. //'smtp_auth' => true,
  104. 'Username' => 'no_reply@email.com',
  105. 'Password' => 'passw0rd',
  106. 'SMTPSecure' => 'tls',
  107. 'Port' => '587', //smtp.gmail.com uses port 465
  108. 'IsHTML' => true,
  109. ClearAddresses(),
  110. ClearReplyTos(),
  111. 'From' => 'no_reply@email.com',
  112. 'FromName' => 'the name',
  113. //'sender_name' => 'the name',
  114. 'Charset' => 'UTF-8',
  115. 'Encoding' => 'base64',
  116. 'ContentType' => 'text/html',
  117.  
  118. 'recipient_email' => 'another@email.com',
  119. 'subject' => 'The subject 2',
  120. 'filter_values' => 'm-sign-up-modal-form-1, captcha, submit-btn, token',
  121. 'Body' => $auto_response,
  122. 'AltBody' => 'Use another another email client',
  123.  
  124. 'SMTPDebug' => '2',
  125. 'Debugoutput' => 'html'
  126. );
  127. if(!$sent_message = Form::sendMail($smtp_settings)){
  128. $msg = '<p class="alert alert-danger">mailforu:' . $smtp_settings->error() . '</p>' . " \n";
  129. exit();
  130. }
  131. else {
  132. $msg = '<p class="alert alert-success">Message successfully sent</p>' . " \n";
  133. Form::clear('m-sign-up-modal-form-1');
  134. };
  135. }
  136. }
  137. }
  138. }
  139. }
  140.  
  141.  
  142. /* ==================================================
  143. The Sign Up Form
  144. ================================================== */
  145.  
  146. $form = new Form('m-sign-up-modal-form-1', 'vertical', 'novalidate', 'material');
  147. $form->addInput('text', 'user-name', '', 'username', 'required');
  148. $form->addInput('email', 'user-email', '', 'e-mail address', 'required');
  149. $form->addPlugin('passfield', '#user-password', 'lower-upper-number-symbol-min8');
  150. $form->addHelper('password must contain lowercase + uppercase letters + number + symbol and be 8 characters long', 'user-password');
  151. $form->addInput('password', 'user-password', '', 'password', 'required');
  152. $form->addHtml('<p>&nbsp;</p>');
  153. $form->addHtml('<div class="text-center">');
  154. $form->addRecaptcha('xyz');
  155.  
  156. // Change here name of modal too
  157. $form->addBtn('button', 'cancel-btn', 1, 'Cancel', 'class=btn btn-default, data-modal-close=!!!!!!', 'submit_group');
  158.  
  159. $form->addBtn('submit', 'submit-btn', 1, 'Send <span class="glyphicon glyphicon-envelope append"></span>', 'class=btn btn-success', 'submit_group');
  160. $form->printBtnGroup('submit_group');
  161. $form->addHtml('</div>');
  162. $form->modal('#modalJoin');
  163.  
  164. // jQuery validation
  165. $form->addPlugin('formvalidation', '#m-sign-up-modal-form-1');
  166.  
  167. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement