migli

migli supports this item

Supported

This author's response time can be up to 1 business day.

424 comments found.

Hello, a presale question Can i save form data to database without sending them per e-mail?

migli

migli Author

Hi,

Yes you can. You can see a database update example at https://www.phpformbuilder.pro/templates/bootstrap-4-forms/default-db-values-form.php (click the “view source code” button).

Documentation about the Mysql class is available here: https://www.phpformbuilder.pro/documentation/class-doc.html#database-main

If you need anything else you’re welcome,

Gilles

Hi,

1) I did the test it works properly I even created two email templates for

The rest of the values are in French except the four here in the mail that I receive, they are always by default

            'last-name'                     => 'Nom',
            'first-name'                    => 'Prénom',
            'user-email'                    => 'Email',
            'user-phone'                    => 'Téléphone',

2) I am not finding the file with SQL tables, for Category and Product?

Thank you

Hello,

Need help, please

I did everything you said to do, it still does not work Both mail templates are created All the code is well integrated on the contact page

Can I give you the FTP details for you to take a look at? something is not working

Give me your email address so that I send you the FTP details

The file after 3600 seconds I even tested 10 seconds, it is still not delete automatically Several unsuccessful trials

The file is present in the FTP but not in mail, I am talking about downloading the file received by the client from the mailbox?

Listen I’m giving up, it still does not work The fields here “First name, Last name, User email, User phone” are not changed, they are always by default

Thank you

Hi,

As I told you before, I’m here to help but not to do your work for free.
We exchanged dozen messages and I spent hours to help you.
I told you what to do:

- double-check your file path
- change your fields names.

Thanks,

Gilles

Hi Gilles,

1) I already check our file path it is good Folder here “file-uploads” is in the root of the site The folder path is good,

I receive the client file sent from the contact form, There is a problem the function side the file is still not delete from the server after 3600 or 10 seconds.

There is also a problem, I do not receive the file on my mailbox? sent by the customer?

2) I already change the names of our fields, it does not work They are always show by default in my mailbox I have no problem with the other fields, the other fields are displayed in French, I only have the problem with the four fields here

I have already done 20 tests

In the folder / phpformbuilder / mailer / email-templates-custom I copy the file here “default-styled.html” admin I copy the file here “default-styled.html” customer

client side the fields are well change because I delete the shortcode “{table}” by default?

admin side the 4 fields are not change because I leave the shortcode “{table}” by default?

On the contact form I add the code here for client is admin

Customer code Attached image https://catup.pw/2Fc8wVo Admin code Attached image https://catup.pw/2qWVAxj
use fileuploader\server\FileUploader;
use phpformbuilder\Form;
use phpformbuilder\Validator\Validator;

// ajoutez la ligne ci-dessous à votre code:
ini_set('display_errors', 1);

/* =============================================
    démarrer la session et inclure la classe de formulaire
============================================= */

session_start();
include_once rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/phpformbuilder/Form.php';

// inclure le téléchargement du fichier
include_once rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/phpformbuilder/plugins/fileuploader/server/class.fileuploader.php';

/* =============================================
Supprimer tous les fichiers téléchargés en charge pour garder mon serveur propre
(Retirez-le si vous ne voulez pas supprimer les fichiers téléchargés)
============================================= */

function cleanDir($dir)
{
    $files = glob($dir); // obtenir tous les noms de fichiers présents dans le dossier
    foreach ($files as $file) { //Itérer des fichiers
        if (is_file($file) && basename($file) != 'art-creative-metal-creativity.jpg') {
            if (time() - filectime($file) > 10) { // si le fichier date d'une heure (3600 secondes), supprimez-le
                unlink($file); // supprimer le fichier
            }
        }
    }
}

cleanDir(define(‘ROOT’, rtrim($_SERVER[‘DOCUMENT_ROOT’], DIRECTORY_SEPARATOR)) . '/file-uploads/images/thumbs/lg/*');
cleanDir(define(‘ROOT’, rtrim($_SERVER[‘DOCUMENT_ROOT’], DIRECTORY_SEPARATOR)) . '/file-uploads/images/thumbs/md/*');
cleanDir(define(‘ROOT’, rtrim($_SERVER[‘DOCUMENT_ROOT’], DIRECTORY_SEPARATOR)) . '/file-uploads/images/thumbs/sm/*');
cleanDir(define(‘ROOT’, rtrim($_SERVER[‘DOCUMENT_ROOT’], DIRECTORY_SEPARATOR)) . '/file-uploads/images/*');
cleanDir(define(‘ROOT’, rtrim($_SERVER[‘DOCUMENT_ROOT’], DIRECTORY_SEPARATOR)) . '/file-uploads/*');

// copier l'image de démonstration dans les téléchargements de fichiers si elle a été supprimée par un utilisateur
if ($_SERVER['SERVER_NAME'] == 'https://www.exemple.com') {
    if (!file_exists(define(‘ROOT’, rtrim($_SERVER[‘DOCUMENT_ROOT’], DIRECTORY_SEPARATOR)) . '/file-uploads/images/art-creative-metal-creativity.jpg')) {
        copy(define(‘ROOT’, rtrim($_SERVER[‘DOCUMENT_ROOT’], DIRECTORY_SEPARATOR)) . '/assets/images/art-creative-metal-creativity.jpg', (define(‘ROOT’, rtrim($_SERVER[‘DOCUMENT_ROOT’], DIRECTORY_SEPARATOR)) . '/file-uploads/images/art-creative-metal-creativity.jpg');
    }
}

/* =============================================
    validation si posté
============================================= */

if ($_SERVER["REQUEST_METHOD"] == "POST" && Form::testToken('contact-form-1') === true) {
    // créer un validateur et valider automatiquement les champs obligatoires
    $validator = Form::validate('contact-form-1', 'fr');

    // validation supplémentaire
    $validator->maxLength(800)->validate('message');
    $validator->email()->validate('user-email');

    // validation captcha
    $validator->captcha('captcha')->validate('captcha');

    // validation cgu
    if (!isset($_POST['cgu'])) {
        $validator->required('Merci de valider les termes et condition')->validate('cgu');
    }

    // vérifier les erreurs
    if ($validator->hasErrors()) {
        $_SESSION['errors']['contact-form-1'] = $validator->getAllErrors();
    } else {
        // télécharger fichier
        $path = rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/file-uploads/';
        $attachments = '';
        if (isset($_POST['attachment']) && !empty($_POST['attachment'])) {
            $posted_img = FileUploader::getPostedFiles($_POST['attachment']);
            $attachments = $path . $posted_img[0]['file'];
        } 

        // template pierre de sable admin
        $admin = array(
            'tpl-header-image'              => 'https://www.exemple.com/images/preview-600-160.png',
            'tpl-page-background'           => 'url(https://www.exemple.com/images/noisy-sandy-stone.png) repeat #002f2f',
            'tpl-content-dark-background'   => '#a7a37e',
            'tpl-content-light-background'  => '#f9f8e9',
            'tpl-content-dark-text'         => '#333333',
            'tpl-content-light-text'        => '#f9f8e9',
            'tpl-content-accent-text'       => '#f9f8e9',
            'tpl-content-accent-background' => '#198181',
            'IP'                            => 'IP visiteur',
            'civility'                      => 'Civilité',
            'user-name'                     => 'Nom',
            'user-first-name'               => 'Prénom',
            'user-email'                    => 'Email', 
            'user-phone'                    => 'Téléphone',
            'department'                    => 'Département',
            'urgency'                       => 'Priorité',
            'subject'                       => 'Sujet',
            'message'                       => 'Message',
            'attachment'                    => 'Glisser déposer',
            'drag-and-drop'                 => 'Glisser déposer',
            'newsletter'                    => 'Bulletin',
            'cgu'                           => 'Termes et condition'
        );
        // template café client
        $client = array(
            'tpl-header-image'              => 'https://www.exemple.com/images/preview-600-160.png',
            'tpl-page-background'           => 'url(https://www.exemple.com/images/noisy-coffee.png) repeat #4d3e39',
            'tpl-content-dark-background'   => '#222222',
            'tpl-content-light-background'  => '#f3f0e6',
            'tpl-content-dark-text'         => '#222222',
            'tpl-content-light-text'        => '#f3f0e6',
            'tpl-content-accent-text'       => '#ffffff',
            'tpl-content-accent-background' => '#db7447',
            'user-name'                     => 'Nom',
            'user-first-name'               => 'Prénom',
            'user-email'                    => 'Email',            
            'service-name'                  => 'assistance technique',
        ); 
        // mail 1 admin
        $email_config = array(
            'sender_email'                  => 'exemple@gmail.com',
            'sender_name'                   => 'Formulaire de contact',
            'reply_to_email'                => $_POST['user-email'],
            'recipient_email'               => 'exemple@gmail.com',
            'subject'                       => 'Formulaire rempli depuis le site web',
            'attachments'                   =>  $attachments,
            'template'                      => 'admin-email.html',
            'custom_replacements'           =>  $admin,            
            'filter_values'                 => 'contact-form-1',
            'values'                        =>  $_POST,
            'sent_message'                  => '<div class="alert alert-success">Votre message a été envoyé avec succès!</div>',
            'debug'                         => true
        );
        // mail 2 client
        $email_configs = array(
            'sender_email'                  => 'contact@exemple.com',
            'sender_name'                   => 'Formulaire de contact',
            'recipient_email'               => addslashes($_POST['user-email']),
            'subject'                       => 'Merci pour votre mail',
            'template'                      => 'client-email.html',
            'custom_replacements'           => $client,
            //'filter_values'                 => 'contact-form-1, email-styles, captcha, captchaHash, submit-btn, token',
            'filter_values'                 => 'contact-form-1',
            'sent_message'                  => '<div class="alert alert-success">Votre message a été envoyé avec succès!</div>',
            'debug'                         => true
        );
        // envoie
        $sent_message = Form::sendMail($email_config);
        $sent_messages = Form::sendMail($email_configs);
        Form::clear('contact-form-1');
    }
}

/* ==================================================
    La forme
================================================== */

$form = new Form('contact-form-1', 'horizontal', 'novalidate', 'bs4');
$form->startFieldset('Merci de remplir ce formulaire pour nous contacter');
$form->addHtml('<p class="text-warning">Tous les champs sont requis</p>');
$form->addInput('hidden', 'IP visiteur', $_SERVER["REMOTE_ADDR"]);

// civilité
$form->setCols(4, 8);
$form->addOption('civility', 'M.', 'M.');
$form->addOption('civility', 'Madame', 'M<sup>adame</sup>');
$form->addOption('civility', 'Mme', 'M<sup>me</sup>');
$form->addSelect('civility', 'Civilité', 'class=select2, data-width=100%, required');

// nom prénom adresse mail tel
$form->setCols(4, -1);
$form->groupInputs('user-first-name', 'user-name');
$form->addHelper('Prénom', 'user-first-name');
$form->addInput('text', 'user-first-name', '', 'Nom complet/Prénom: ', 'required, placeholder=paul');
$form->addHelper('Nom de famille', 'user-name');
$form->addInput('text', 'user-name', '', '', 'required, placeholder=dupont');
$form->groupInputs('user-email', 'user-phone');
$form->addHelper('E-Mail', 'user-email');
$form->addInput('email', 'user-email', '', 'E-Mail/Téléphone: ', 'required, placeholder=dupont@free.fr');
$form->addHelper('Téléphone', 'user-phone');
$form->addInput('tel', 'user-phone', '', '', 'required, data-fv-intphonenumber=true');

// département
$form->groupInputs('department', 'urgency');
$form->setCols(4, 3);
$form->addRadio('department', 'Support', 'Support');
$form->addRadio('department', 'Compte (premium)', 'Compte (premium)');
$form->addRadio('department', 'Facturation (premium)', 'Facturation (premium)');
$form->addRadio('department', 'Retour d\'information', 'Retour d\'information');
$form->addRadio('department', 'Autre', 'Autre');
$form->printRadiogroup('department', 'Département', false, 'required');

// priorité
$form->setCols(2, 3);
$form->addRadio('urgency', 'Faible', 'Faible');
$form->addRadio('urgency', 'Moyen', 'Moyen');
$form->addRadio('urgency', 'Haute', 'Haute');
$form->addRadio('urgency', 'Urgent', 'Urgent');
$form->printRadiogroup('urgency', 'Priorité', false, 'required');
$form->setCols(4, 8);

// message
$form->addTextarea('message', '', 'Merci de décrire votre problème', 'cols=20, rows=8, required, placeholder=S\'il vous plaît en dire plus sur votre demande ...');

// glisser déposer
$fileUpload_config = array(
    'xml'           => 'drag-and-drop',
    'upload_dir'    => '../../../../../file-uploads/', // le répertoire pour télécharger les fichiers. relatif à phpformbuilder/plugins/fileuploader/default/php/ajax_upload_file.php
    'limit'         => 1, // max. nombre de fichiers
    'file_max_size' => 5, // chaque taille maximale du fichier en Mo {null, Number}
    'extensions'    => ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'txt'],
    'debug'         => true // consignez le résultat dans la console du navigateur et affiche un texte d'erreur sur la page si le téléchargeur ne parvient pas à analyser le résultat json.
);
//$form->startFieldset('Glisser déposer');
$form->addHelper('Types de fichiers acceptés : .pdf, .doc[x], .xls[x], .txt', 'drag-and-drop', 'after');
$form->addFileUpload('file', 'drag-and-drop', '', 'Glisser déposer', '', $fileUpload_config);
$form->endFieldset();

// newsletter
$form->addCheckbox('newsletter', 'S\'inscrire à la Newsletter', 1, 'checked=checked');
$form->printCheckboxGroup('newsletter', '');

// termes et condition
$form->addCheckbox('cgu', 'J\'ai lu et accepté les <a href="#" data-toggle="modal" data-target="#largeModal">termes et condition</a>', 'cgu', 1, 'checked=checked');
$form->printCheckboxGroup('cgu', '');

// captcha
$form->addInput('text', 'captcha', '', 'Tapez les caractères suivants :', 'size=15, required');
$form->addPlugin('captcha', '#captcha');

// envoyé le message
$form->addBtn('reset', 'reset-btn', 1, 'Réinitialiser <i class="fa fa-ban" aria-hidden="true" />', 'class=btn btn-warning', 'my-btn-group');
$form->addBtn('submit', 'submit-btn', 1, 'Soumettre <i class="fa fa-envelope append" aria-hidden="true" />', 'class=btn btn-success ladda-button, data-style=zoom-in', 'my-btn-group');
$form->printBtnGroup('my-btn-group');
$form->endFieldset();

// mot-caractère-mot-clé
$form->addPlugin('word-character-count', '#message', 'default', array('%maxAuthorized%' => 800));

// radio personnalisée et case à cocher css
$form->addPlugin('nice-check', 'form', 'default', ['%skin%' => 'green']);

// numéros de téléphone internationaux
$form->addPlugin('intl-tel-input', 'input[type=tel]');

// validation jQuery
$form->addPlugin('formvalidation', '#contact-form-1', 'bs4-french');
?>

Thank you

phpbuilder can be integrated into wordpress ?, but I need it to be serious in a database.

Thank

migli

migli Author

Hi,

Thanks for purchase.

You can add forms to your pages as shown in the tutorial: https://www.phpformbuilder.pro/documentation/wordpress-cms-users.html

to add/update your database you can use the provided Mysql class and make any query: https://www.phpformbuilder.pro/documentation/class-doc.html#database-main

I hope my answer helps; if not, please detail your question.

Gilles

// check for errors if ($validator->hasErrors()) { $_SESSION‘errors’ = $validator->getAllErrors(); var_dump($_SESSION‘errors’); } else { $email_config = array( ‘sender_email’ => ‘sender@hotmail.com’, ‘sender_name’ => ‘This is the name of the sender’, ‘recipient_email’ => addslashes($_POST[‘user-email’]),

/* [HOW CAN I ADD MY EMAIL ADRES HERE SO THAT I ALSO GET A COPY OF THE FORM] }

'subject'         => 'This is the subject of this mail',
        'filter_values'   => 'contact-form-12'
    );
    $sent_message = Form::sendMail($email_config);
    Form::clear('contact-form-12');
}

I have a question about a form that i try to set up.

This code above works fine

The form itself works well and mails a copy of the values in the field to the user-email

But i can not figure out how to set up the form to send a copy from the filled in form, to my email adres,

I hope i have informed you so enough if you need more info please let me know.

:-)

migli

migli Author

Hi Peter,

Thanks for purchase.

To send a copy you just have to add a “cc” to the sendMail options:

$email_config = array(
        'sender_email'    => 'sender@hotmail.com',
        'sender_name'     => 'This is the name of the sender',
        'recipient_email' => addslashes($_POST['user-email']),
        'cc'              => 'you@your-email.com',
        'subject'         => 'This is the subject of this mail',
        'filter_values'   => 'contact-form-12'
    );
}
$sent_message = Form::sendMail($email_config);
Form::clear('contact-form-12');

Don’t forget to use an email from your domain as sender_email to avoid spam filters

If you need anything else you’re welcome,

Gilles

Thanks for your quick response.

My form is now working perfectly :-)

by
by
by
by
by
by