Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use phpformbuilder\Form;
- use phpformbuilder\Validator\Validator;
- use phpformbuilder\database\Mysql;
- // add this line for debugging
- ini_set('display_errors', 1);
- // ----
- /* =============================================
- start session and include form class
- ============================================= */
- session_start();
- include_once rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/xy/dev/assets/mform/Form.php';
- /* =============================================
- validation if posted
- ============================================= */
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- if(Form::testToken('m-sign-up-modal-form-1') === true) {
- // create validator & auto-validate required fields
- $validator = Form::validate('m-sign-up-modal-form-1');
- // additional validation
- $validator->hasLowercase()->hasUppercase()->hasNumber()->hasSymbol()->minLength(8)->validate('user-password');
- $validator->email()->validate('user-email');
- // // // $validator->maxLength(100)->validate('message');
- // recaptcha validation
- $validator->recaptcha('xyz', 'Recaptcha Error')->validate('g-recaptcha-response');
- // check for errors
- if ($validator->hasErrors()) {
- $_SESSION['errors']['m-sign-up-modal-form-1'] = $validator->getAllErrors();
- $msg = '<p class="alert alert-danger">' . $validator->getAllErrors() . '</p>' . " \n";
- exit();
- } else {
- require_once rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/xy/dev/assets/mform/database/db-connect.php';
- require_once rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/xy/dev/assets/mform/database/Mysql.php';
- $db = new Mysql();
- $insert['ID'] = Mysql::SQLValue('');
- $insert['user-name'] = Mysql::SQLValue($_POST['user-name']);
- $insert['user-email'] = Mysql::SQLValue($_POST['user-email']);
- $insert['user-password'] = Mysql::SQLValue($_POST['user-password']);
- if (!$db->insertRow('avia_signUps', $insert)) {
- $msg = '<p class="alert alert-danger">' . $db->error() . '<br>' . $db->getLastSql() . '</p>' . " \n";
- exit();
- } else {
- $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";
- $smtp_settings = array(
- // MAIL GOES TO FORM_USER
- require rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/mform/mail2admin.php',
- 'Host' => 'send.smtp.com',
- 'SMTPAuth' => true,
- //'smtp_auth' => true,
- 'Username' => 'no_reply@email.com',
- 'Password' => 'passw0rd',
- 'SMTPSecure' => 'tls',
- 'Port' => '587', //smtp.gmail.com uses port 465
- 'IsHTML' => true,
- ClearAddresses(),
- ClearReplyTos(),
- 'From' => 'no_reply@email.com',
- 'FromName' => 'the name',
- //'sender_name' => 'the name',
- 'Charset' => 'UTF-8',
- 'Encoding' => 'base64',
- 'ContentType' => 'text/html',
- 'recipient_email' => addslashes($_POST['user-email']),
- 'addBCC' => 'bcc@email.com',
- 'subject' => 'the subject',
- 'filter_values' => 'm-sign-up-modal-form-1, captcha, submit-btn, token',
- 'Body' => $auto_response,
- 'AltBody' => 'Use another another email client',
- 'SMTPDebug' => '2',
- 'Debugoutput' => 'html'
- );
- // $sent_message = Form::sendMail($smtp_settings);
- if(!$sent_message = Form::sendMail($smtp_settings)){
- $msg = '<p class="alert alert-danger">mailforu:' . $smtp_settings->error() . '</p>' . " \n";
- exit();
- }
- else {
- $smtp_settings = array(
- // MAIL GOES TO ADMIN
- require rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/mform/mail2admin.php',
- 'Host' => 'send.smtp.com',
- 'SMTPAuth' => true,
- //'smtp_auth' => true,
- 'Username' => 'no_reply@email.com',
- 'Password' => 'passw0rd',
- 'SMTPSecure' => 'tls',
- 'Port' => '587', //smtp.gmail.com uses port 465
- 'IsHTML' => true,
- ClearAddresses(),
- ClearReplyTos(),
- 'From' => 'no_reply@email.com',
- 'FromName' => 'the name',
- //'sender_name' => 'the name',
- 'Charset' => 'UTF-8',
- 'Encoding' => 'base64',
- 'ContentType' => 'text/html',
- 'recipient_email' => 'another@email.com',
- 'subject' => 'The subject 2',
- 'filter_values' => 'm-sign-up-modal-form-1, captcha, submit-btn, token',
- 'Body' => $auto_response,
- 'AltBody' => 'Use another another email client',
- 'SMTPDebug' => '2',
- 'Debugoutput' => 'html'
- );
- if(!$sent_message = Form::sendMail($smtp_settings)){
- $msg = '<p class="alert alert-danger">mailforu:' . $smtp_settings->error() . '</p>' . " \n";
- exit();
- }
- else {
- $msg = '<p class="alert alert-success">Message successfully sent</p>' . " \n";
- Form::clear('m-sign-up-modal-form-1');
- };
- }
- }
- }
- }
- }
- /* ==================================================
- The Sign Up Form
- ================================================== */
- $form = new Form('m-sign-up-modal-form-1', 'vertical', 'novalidate', 'material');
- $form->addInput('text', 'user-name', '', 'username', 'required');
- $form->addInput('email', 'user-email', '', 'e-mail address', 'required');
- $form->addPlugin('passfield', '#user-password', 'lower-upper-number-symbol-min8');
- $form->addHelper('password must contain lowercase + uppercase letters + number + symbol and be 8 characters long', 'user-password');
- $form->addInput('password', 'user-password', '', 'password', 'required');
- $form->addHtml('<p> </p>');
- $form->addHtml('<div class="text-center">');
- $form->addRecaptcha('xyz');
- // Change here name of modal too
- $form->addBtn('button', 'cancel-btn', 1, 'Cancel', 'class=btn btn-default, data-modal-close=!!!!!!', 'submit_group');
- $form->addBtn('submit', 'submit-btn', 1, 'Send <span class="glyphicon glyphicon-envelope append"></span>', 'class=btn btn-success', 'submit_group');
- $form->printBtnGroup('submit_group');
- $form->addHtml('</div>');
- $form->modal('#modalJoin');
- // jQuery validation
- $form->addPlugin('formvalidation', '#m-sign-up-modal-form-1');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement