Jump to content

Simple Contact Form


justb3a

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
Link to comment
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
Link to comment
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
Link to comment
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
Link to comment
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
Link to comment
Share on other sites

  • 3 weeks later...

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 ?

Link to comment
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!

Link to comment
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.

Link to comment
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.

Link to comment
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 :)

Link to comment
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 ;) )

Link to comment
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
Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
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!

Link to comment
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
Link to comment
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!

Link to comment
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
×
×
  • Create New...