Jump to content
justb3a

Simple Contact Form

Recommended Posts

Hi @Donald, I recently used this Module and may have some tips, but I don't know it as well as others:

1 hour ago, Donald said:

1. Even if I set "Restrict Submissions" and "Maximum time" very high I can not fill out the form another time for testing purposes. What coud I have probably done wrong? I always get messages like...

I was able to send as many tests as I liked, as long as I had settings:

Minimum time: 1
Maximum time: 300 (i.e. large)
Restrict submissions: 300 (i.e. large)
Exclude IP: 127.0.0.1

Sorry if you have tried exactly this and it doesn't help.

1 hour ago, Donald said:

2. Also I can not find any logfile (at least not in site/modules/simplecontactform) ...???

In the GUI Admin, click Setup > Logs > simplecontactform-log

1 hour ago, Donald said:

3. In the settings area of the module you can also set the fields of the contact form but how can I create a second contact form on another page with totally different fields? 

This is a bit more involved, but essentially read the docs where it tells you how to use an 'options' array, populated with settings. One of the settings in naming the form and naming the fields that form is able to use. Then elsewhere in your template or another template, you do the same but the contents of the 'options' array is different, naming different fields from those available listed in the Module (where you add them). Essentially the Module GUI allows you to insert any fields that will be used across one or more forms and it's the calling of the forms in your code that determines which fields are rendered and used.

I think I have got this correct and I hope it's helpful, very sorry if not.

Good luck!

  • Thanks 2

Share this post


Link to post
Share on other sites

hi @donald

i've never used this module so i cannot provide any support that you requested in the other topic. why don't you just create your own contact form? I'm not talking about creating a module for that. only a template with a simple html form, a honeypot and some lines of code that send you an email and store the results in a page in the backend?

all you need is a form: https://getuikit.com/docs/form

and a template that handles the request (here it handles an ajax request with some json data):

<?php
$email = 'your@mail.com';
$subject = 'your email subject';
$html = "<html><body>";
$formdata = json_decode($formdata);
foreach($formdata as $field) {
    switch($field->name) {
        case 'email':
        case 'name':
        case 'tel':
            $html .= "<p>" . $field->name . ": " . $sanitizer->text($field->value) . "</p>";
            if($field->name == 'email') $email = $sanitizer->email($field->value);
            break;
        case 'message':
            $html .= "<p>" . $field->name . ":<br>---<br>" . nl2br($sanitizer->textarea($field->value)) . "<br>---</p>";
            //${$field->name} = $sanitizer->textarea($field->value);
            break;
        case 'mail':
            // honeypot
            if($field->value) $subject = 'SPAM: '.$subject;
            break;
    }
}
$html .= "</body></html>";

$mail = wireMail();
$mail->to('your@mail.com')->from($email);
$mail->subject($subject);
$mail->bodyHTML($html);
if($mail->send()) { ?>
    <div class="uk-alert uk-alert-success uk-alert-large">
        <p>Thank you!</p>
    </div>
<?php
}
else { ?>
    <div class="uk-alert uk-alert-danger uk-alert-large">
        <p>Error!</p>
    </div>
<?php
}

// save to log that can be viewed via the pw backend
$p = new Page();
$p->template = 'maillogitem';
$p->parent = 1234;
$p->title = date('d.m.Y') . ' - ' . $email;
$p->body = $html;
$p->save();

 

  • Like 6
  • Thanks 1

Share this post


Link to post
Share on other sites
18 hours ago, Donald said:

my personal opinion is that authors should care more about documentation. 

Fell free to improve the documentation! You could easily send a pull request. This is open source. I develop it in my spare time. I don't receive any money doing this. I developed this module for personal use, and thought, it would be nice to share it with others...

On 25/11/2017 at 3:50 PM, Donald said:

but how can I create a second contact form on another page with totally different fields? 

@see: Render multiple instances

18 hours ago, Donald said:

In the log file I always get: Number of fields does not match

To figure out what causes this, it would be a good starting point to provide a bit more information. For example: which fields are added, how do you execute the module---...

  • Like 5

Share this post


Link to post
Share on other sites
Quote

Number of fields does not match

Do you have an email field in the form? Make sure that in this field settings under input -> verify email address is not checked.

the form is counting this field as two fields instead of one and you will get that error.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
16 hours ago, Donald said:

1. Do you also know how to set the options or configure that not just the admin gets an email with the data which was filled in by the sender but also that every sender of an form gets an email back when he/she/(it) filled in a valid email-address?

@see: How to send more than one email

  • Thanks 1

Share this post


Link to post
Share on other sites
On 27/11/2017 at 7:32 PM, Donald said:

3. At the moment are just basic test fields are added like name, street ...

Just basic test fields.. sometimes just some basic fields do break something. If I know that you use an email field with the checked option verify email address, it's pretty easy for me to submit a hotfix and exclude it from the counter. Thanks @maxf5 for pointing it out.

On 27/11/2017 at 7:32 PM, Donald said:

. Also I do not understand when to use the prefix scf_ and when not

You don't have to use the prefix at all. All fields which are added by the module will be prefixed – just to make sure the name has not been chosen yet. Please do not rename scf_website and scf_date because they are used for spam tests. The rest is up to you!

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

Version 1.0.7 excludes email and password confirmation fields from spam count.

@Donald I hope, I've answered all your questions. Now I'm looking forward to merge your pull request to improve the documentation! ;) ^_^

  • Like 2

Share this post


Link to post
Share on other sites

I have two forms, each on different pages, each with `submitName` values that are unique, in case that helps, and I am finding after a succsessful form submission, if I navigate to a new page, then let the page load then go back in history, to the page where the form was sent from, my browser is complaining `Confirm Form Resubmission`.

I can't see anything in the docs on how to clear POST data on a succsessful submission, assuming it's that.

Any pointers/help would be much appreciated :) Thanks in advance 👍

Share this post


Link to post
Share on other sites

Hello! I am trying get the plugin working correctly on my dev server and I am having a weird issue. I can get the fields to work for a few minutes (even so far as being able to use the form and receive an email) but after a few minutes to an hour the plugin resets, clearing the fields and the to email field. Any idea what could possibly cause something like this?

Thanks!

Share this post


Link to post
Share on other sites

@Thomasaurus Always worth checking the anti-spam settings to make sure it's not one of those tripping over. The only other thing I've had that I think was similar was when I had two tabs open, signed in as admin - got weird stuff happening nothing to do with SCF specifically but it affected session info - closed one tab, instant fix. Good luck, I am using this Module more now I am getting familiar with it, it's super useful.

Share this post


Link to post
Share on other sites

Thanks @bernhard by coincidence I am on that exact page now ^_^ I've tried some of this before but not this exact page. It looks like I can 100% solve it by redirecting to a new page (the module allows me to do this), but if I do then the module's nice support for a `Success` message is lost, so no error but also no message.

Gonna keep experimenting to see if I can get the best of both worlds.

Share this post


Link to post
Share on other sites

of course you can! just clear your post data and redirect to the same page. If you do not show the submitted data, then this works (for example if you had a general "thanks for your message").

if you want to show data to the user (like "thanks alan for your message, we'll contact you soon") you could save that data to $session and display it from the session variable after clearing the post data.

edit: actually the post data should get cleared already by the redirect :)

Share this post


Link to post
Share on other sites

Yes, can do that, thanks again @bernhard but it feels like this is something the SCF module does already, e.g. it supports setting a success message in a set of JSON options, and indeed it then shows the message. So all looks 100% ok, unless I nav to some other page, then go back. Maybe a bug in the module (doubt it, more likely a bug in me ;) )

Share this post


Link to post
Share on other sites
Just now, bernhard said:

Ok sorry i shut up since I don't have a clue about this module :)

;) NO! Chat sometimes results in a solution, even if one doesn't know about a thing ;)

Thanks for trying and Happy Christmas in Austria \o/

  • Like 1

Share this post


Link to post
Share on other sites

Hi David,

I just upgraded from ProcessWire v2.8 to v3.0.87, and it offered to automatically upgrade my SimpleContactForm module (from v0.2.1)

This resulted in the following error:

Quote

Error: [] operator not supported for strings (line 133 of .../site/modules/SimpleContactForm/SimpleContactForm.module)

Any ideas how to fix this?

SCF.jpg

Share this post


Link to post
Share on other sites

Sorry, deleted my previous wrong answer.

Edited by horst

Share this post


Link to post
Share on other sites
On 1/1/2018 at 10:01 PM, horst said:

Sorry, deleted my previous wrong answer.

It seems the immediate problem is that $this->allFields is a string instead of an array, but the question is why?

Share this post


Link to post
Share on other sites

I just installed this module to do a basic test.

I don't see the error @dougwoodrow sees, but I'm having a problem with mails not being sent.

Log from module: "[ERROR] Mail has not been sent to ..."

Log from Wiremailsmtp_errors: Error in hnsmtp::send : cannot connect to smtp-server!

Share this post


Link to post
Share on other sites
1 hour ago, dragan said:

Log from Wiremailsmtp_errors: Error in hnsmtp::send : cannot connect to smtp-server!

You need to check / debug WireMailSmtp settings, (its module config screen).

  • Like 1

Share this post


Link to post
Share on other sites

Yep - that did it (I installed WireMailSmtp, but I'm not sure I ever actually used it...). Thanks!

Share this post


Link to post
Share on other sites

@dougwoodrow I guess, $this->allFields doesn't return an array due to module update issues v0.2.1 -> v1.0.7. I'm not quite sure if it works to update directly, I tried to keep everything downward compatible, but this is a really huge difference.. You could try to update version by version and always make sure to save module settings. Otherwise you could try to update the module settings json manually (not recommended but maybe the only way; edit column data in table modules, row where class equals SimpleContactForm).

@alan There' s a new module version (1.0.8) which adds an option to prevent form resubmission (activate checkbox in module settings).

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
20 hours ago, justb3a said:

There' s a new module version (1.0.8) which adds an option to prevent form resubmission (activate checkbox in module settings).

@justb3a Thank you very much for this, 100% fixed the problem, cheers!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By gebeer
      I am happy to present my new fieldtype FieldtypeImageFromPage. It is made up of 2 modules:
      Fieldtype Image Reference From Another Page is a Fieldtype that stores a reference to a single image from another page. The image can be selected with the associated Inputfield.
      Inputfield Select Image From Page is an Inputfield to select a single image from images on a predefined page and it's children.
      And there also is a helper module that takes care of cleanup tasks.
      This module evolved out of a discussion about my other Module FieldtypeImagePicker.  It caters for use cases where a set of images is being reused multiple times across a site. With this fieldtype these images can be administered through a chosen page. All images uploaded to that page will be available in the inputfield.
      When to use ?
      Let editors choose an image from a set of images that is being used site-wide. Ideal for images that are being re-used across the site.
      Suited for images that are used on multiple pages throughout the site (e.g. icons).
      Other than the native ProcessWire images field, the images here are not stored per page. Only references to images on another page are stored. This has several advantages:
      one central place to organize images when images change, you only have to update them in one place. All references will be updated, too. (Provided the name of the image that has changed stays the same) Features
      Images can be manipulated like native ProcessWire images (resizing, cropping etc.) Image names are fully searchable through the API Accidental image deletion is prevented. When you want to delete an image from one of the pages that hold your site-wide images, the module searches all pages that use that image. If any page contains a reference to the image you are trying to delete, deletion will be prevented. You will get an error message to help you edit those pages and remove references there before you can finally delete the image. How to install and setup
      Download and install this module like any other modules in ProcessWire Create a page in the page tree that will hold your images. This page's template must have an images field Upload some images to the page you created in step 2 Create a new field. As type choose 'Image Reference From Another Page'. Save the field. In 'Details' Tab of the field choose the page you created in step 2 Click Save button Choose the images field name for the field that holds your images (on page template from step 2) Click Save button again Choose whether you want to include child pages of page from step 2 to supply images Add the field to any template You are now ready to use the field View of the inputfield on the page edit screen:

      View of the field settings

      The module can be installed from this github repo. Some more info in the README there, too.
      In my tests it was fairly stable. After receiving your valued feedback, I will eventually add it to the modules directory.
      My ideas for further improvement:
      - add ajax loading of thumbnails
      Happy to hear your feedback!
       
    • By gebeer
      Although the PW backend is really intuitive, ever so often my clients need some assistance. Be it they are not so tech savvy or they are not working in the backend often.
      For those cases it is nice to make some help videos available to editors. This is what this module does.
      ProcessHelpVideos Module
      A Process module to display help videos for the ProcessWire CMS. It can be used to make help videos (screencasts) available to content editors.
      This module adds a 'Help Videos" section to the ProcessWire backend. The help videos are accessible through an automatically created page in the Admin page tree. You can add your help videos as pages in the page tree. The module adds a hidden page to the page tree that acts as parent page for the help video pages. All necessary fields and templates will be installed automatically. If there are already a CKEditor field and/or a file field for mp4 files installed in the system, the module will use those. Otherwise it will create the necessary fields. Also the necessary templates for the parent help videos page and it's children are created on module install. The module installs a permission process-helpvideos. Every user role that should have access to the help video section, needs this permission. I use the help video approach on quite a few production sites. It is stable so far and well received by site owners/editors. Up until now I installed required fields, templates and pages manually and then added the module. Now I added all this logic to the install method of the module and it should be ready to share.
      The module and further description on how to use it is available on github: https://github.com/gebeer/ProcessHelpVideos
      If you like to give it a try, I am happy to receive your comments/suggestions here.
    • By Robin S
      A module created in response to the topic here:
      Page List Select Multiple Quickly
      Modifies PageListSelectMultiple to allow you to select multiple pages without the tree closing every time you select a page.
      The screencast says it all:

       
      https://github.com/Toutouwai/PageListSelectMultipleQuickly
      https://modules.processwire.com/modules/page-list-select-multiple-quickly/
    • By gebeer
      Hello all,
      sharing my new module FieldtypeImagePicker. It provides a configurable input field for choosing any type of image from a predefined folder.
      The need for it came up because a client had a custom SVG icon set and I wanted the editors to be able to choose an icon in the page editor.
      It can also be used to offer a choice of images that are used site-wide without having to upload them to individual pages.
      There are no image manipulation methods like with the native PW image field.
      Module and full description can be found on github https://github.com/gebeer/FieldtypeImagePicker
      Kudos to @Martijn Geerts. I used his module FieldTypeSelectFile as a base to build upon.
      Here's how the input field looks like in the page editor:

      Hope it can be of use to someone.
      If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Eventually this will go in the module directory soon, too.
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://github.com/BernhardBaumrock/RockPDF
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
×
×
  • Create New...