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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By joshua
      This module is (yet another) way for implementing a cookie management solution.
      Of course there are several other possibilities:
      - https://processwire.com/talk/topic/22920-klaro-cookie-consent-manager/
      - https://github.com/webmanufaktur/CookieManagementBanner
      - https://github.com/johannesdachsel/cookiemonster
      - https://www.oiljs.org/
      - ... and so on ...
      In this module you can configure which kind of cookie categories you want to manage:

      You can also enable the support for respecting the Do-Not-Track (DNT) header to don't annoy users, who already decided for all their browsing experience.
      Currently there are four possible cookie groups:
      - Necessary (always enabled)
      - Statistics
      - Marketing
      - External Media
      All groups can be renamed, so feel free to use other cookie group names. I just haven't found a way to implement a "repeater like" field as configurable module field ...
      When you want to load specific scripts ( like Google Analytics, Google Maps, ...) only after the user's content to this specific category of cookies, just use the following script syntax:
      <script type="text/plain" data-type="text/javascript" data-category="statistics" data-src="/path/to/your/statistic/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing" data-src="/path/to/your/mareketing/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="external_media" data-src="/path/to/your/external-media/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing">console.log("Inline scripts are also working!");</script> The type has to be "optin" to get recognized by PrivacyWire, the data-attributes are giving hints, how the script shall be loaded, if the data-category is within the cookie consents of the user. These scripts are loaded asynchronously after the user made the decision.
      If you want to give the users the possibility to change their consent, you can use the following Textformatter:
      [[privacywire-choose-cookies]] It's planned to add also other Textformatters to opt-out of specific cookie groups or delete the whole consent cookie.
      You can also add a custom link to output the banner again with a link / button with following class:
      <a href="#" class="privacywire-show-options">Show Cookie Options</a> <button class="privacywire-show-options">Show Cookie Options</button> This module is still in development, but we already use it on several production websites.
      You find it here: PrivacyWire Git Repo
      Download as .zip
      I would love to hear your feedback 🙂
      CHANGELOG
      0.1.1 Debugging: fixed error during uninstall 0.1.0 Added new detection of async scripts for W3C Validation 0.0.6 CSS-Debugging for hiding unused buttons, added ProCache support for the JavaScript tag 0.0.5 Multi-language support included completely (also in TextFormatter). Added possibility to async load other assets (e.g. <img type="optin" data-category="marketing" data-src="https://via.placeholder.com/300x300">) 0.0.4 Added possibility to add an imprint link to the banner 0.0.3 Multi-language support for module config (still in development) 0.0.2 First release 0.0.1 Early development
    • By bernhard
      --- Please use RockFinder3 ---
    • By MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory (pending approval) If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
    • By Craig
      I've been using Fathom Analytics for a while now and on a growing number of sites, so thought it was about time there was a PW module for it.
      WayFathomAnalytics
      WayFathomAnalytics is a group of modules which will allow you to view your Fathom Analytics dashboard in the PW admin panel and (optionally) automatically add and configure the tracking code on front-end pages.
      Links
      GitHub Readme & documentation Download Zip Modules directory Module settings screenshot What is Fathom Analytics?
      Fathom Analytics is a simple, privacy-focused website analytics tool for bloggers and businesses.

      Stop scrolling through pages of reports and collecting gobs of personal data about your visitors, both of which you probably don't need. Fathom is a simple and private website analytics platform that lets you focus on what's important: your business.
      Privacy focused Fast-loading dashboards, all data is on a single screen Easy to get what you need, no training required Unlimited email reports Private or public dashboard sharing Cookie notices not required (it doesn't use cookies or collect personal data) Displays: top content, top referrers, top goals and more
    • By daniels
      This is a lightweight alternative to other newsletter & newsletter-subscription modules.
      You can find the Module in the Modules directory and on Github
      It can subscribe, update, unsubscribe & delete a user in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin.
      This module fits your needs if you...
      ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe, update, unsubscribe or delete users to/from different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns *I have only tested it with PHP 7.x so far, so use on owners risk
      EDIT:
      Since 0.0.4, instructions and changelog can be found in the README only. You can find it here  🙂
      If you have questions or like to contribute, just post a reply or create an issue or pr on github, thanks!
×
×
  • Create New...