Jump to content

Simple Contact Form


justb3a

Recommended Posts

Hi Congomonster,

you have to change the fieldname. in your case scf_fullName in e.g. scf_Nachname. Be carefull. the prefix scf_ is important.

And you also have to change the values ( input - Tag ) in your form. But here you go without the prefix!

Don´t forget to adapt the fieldnames in your modulconfiguration. also without the prefix.

Hi itsberni,

thank you for answer. It worked except for the date field. :frantics:

For now it's perfect! :biggrin:

Link to comment
Share on other sites

@itsberni: 60 is not enough. Try the following values:

max_execution_time = 240
max_input_time = 240
memory_limit = 1024M 

thanks, justb3a - i've tried this values.

After a very long period of time, the mails are appearing.

I think that's way to long. Could that be caused by the repeater, that slows down everthing in my case?!

the contactform is in a testphase already, so there are a lot of entries ( about 180 ).

If i try to delete data in the repeater, the script tooks again a very long period of time an after that, the tagged

data is not deleted. :(

Any ideas though?

Link to comment
Share on other sites

  • 3 weeks later...

Can anybody help me?

I have been trying for two full days to get this module running - thats OK because I am still learning. With everything else so far (e.g. include a simpler contact form and make it work) I was able to figure it out by modifying stuff I found elsewhere but now I am stuck.

I installed the module, set up the template file and the HTML works: I get a page with fields and I can enter data. But when I press „submit“ nothing happens. I get no error message, nothing.

I have tried to address the module through php and through JS, I tried hundreds of variations of syntax, it seems I do something wrong addressing the module.

Could anybody please supply me with an example for a full and correct code and let me know where to insert it?

Thanks A LOT!

Link to comment
Share on other sites

@Kami: Please have a look at your log file (simplecontactform-log). 

Edit: Please set $config->debug in site/config.php to true and try again  ^_^

@itsberni: Sorry for answering that late. I guess we must transfer the form action to the frontend by using pagination (20 entrys a page).

Link to comment
Share on other sites

And no error message appears (frontend or error log). Does it reload the page if you press submit? Is there an entry in  simplecontactform-spam-log? There is a setting called antiSpamTimeMin, if you submit the form really fast, the content will be treated as spam. There should be an entry in the spam log. Try to set this setting (in module settings) to 0.

Link to comment
Share on other sites

There is an error message but it concerns a template I don´t use (?) so I am not sure it is related: "Error: Call to undefined function renderNav() (line 12 of /Applications/MAMP/htdocs/site/templates/basic-page.php)". Line 12 is: "renderNav($page->children);".

There is an entry in the spam-log but its date is from yesterday: "CSRF Token validation failed."
 

The page seems to reload when I press submit, it keeps the entries in "name" and "email" but not the entry in the message field. AntiSpamTimeMin is set to 0.

Link to comment
Share on other sites

There is an error message but it concerns a template I don´t use (?) so I am not sure it is related: "Error: Call to undefined function renderNav() (line 12 of /Applications/MAMP/htdocs/site/templates/basic-page.php)". Line 12 is: "renderNav($page->children);".

This is another error message which is not related to this module. Somewhere in your template you call renderNav($page->children) but this function doesn't exist. This function comes with a basic ProcessWire installation and is located in _func.php which is required by _init.php ($config->prependTemplateFile in config.php)

There is an entry in the spam-log but its date is from yesterday: "CSRF Token validation failed."

This module uses CSRF token validation, if you don't know what it's all about, have a look here. In your form there must be an hidden input field, make sure that it's still there (<input type='hidden' name='<?= $input->tokenName; ?>' value='<?= $input->tokenValue; ?>' class='_post_token' />).

Check also that there is another hidden input field: <input type="hidden" name="submitted" value="1">. Do not remove one of them!

Link to comment
Share on other sites

@Bam Bino: Did you remove some fields? I can't see scf-website as well as submitted. These fields are necessary for validation. If I just install the module without any config / html - css adaptions, it should look like this:

post-2759-0-79695600-1436778971_thumb.pn

Link to comment
Share on other sites

The scf-date field should be invisible as well. Please add in site/modules/SimpleContactForm/SimpleContactForm.module after line 424 var_dump($field); and paste the output (make sure $config->debug is set to true in site/config.php):

foreach ($form as $field => $value) {
  if (empty($value)) {
    var_dump($field);
    $error = true;
    continue;
  }
}
Link to comment
Share on other sites

Hi, justb3a. I did as you instructed, but I get zero output of var_dump when I submit the form. It goes like this:

1. I fill the form

lhXkJp7.png

2. When I submit it I get the error message:

yfQaRh8.png

3. When I resubmit the form I am redirected to home page:

pZB6qlt.png

4. As modules documentation says it means that it was marked as spam, so I open simplecontactform-spam-log.txt for the error information"

4gm8Cef.png

Link to comment
Share on other sites

  • 3 weeks later...

I've run into an issue where if I trigger an error state (say by leaving the form blank or by skipping a required field) the next submission always redirects to the homepage while generating a "CSRF Token validation failed" message. Everything else is working presently. Any ideas?

(PW 2.6.1)

I have a couple of small feature suggestions that would be nice: 1) The ability to assign a "From" name for generated emails; 2) The ability to send messages to multiple recipients. Thanks!

Link to comment
Share on other sites

  • 2 weeks later...

Hello,

I just need to setup a simple contact form so, I installed SimpleContactForm.

Then I went to Admin >> ModulesSimple >> Contact Form and followed the instruction.

After I included below code into my contact.php and refresh the page, nothing came out @ blank page.

<?php $modules->get('SimpleContactForm')->render(); ?>

If I have the budget I could buy myself the FormBuilder but sadly not so much at the moment.

Please tell me, is there any way to fix this issue or if there's something I overlooked ?

Thank you.

Edited by kongondo
Merged to SimpleContactForm's support forum
Link to comment
Share on other sites

I have managed to call the contact form by adding echo

<?php echo $modules->get('SimpleContactForm')->render(); ?> 

 but there are 2 more issues :

1) How do you replace unordered list bullets which appear near the form label ?

post-3657-0-81343700-1439976399_thumb.pn

2) When I submitted the form my browser got redirected to the Home page and found out the simple_contact_form.php don't have any value in action="./" . How to fix this ?

post-3657-0-75658500-1439976609_thumb.pn

Thank you

Link to comment
Share on other sites

@kradzcalypse:

1) A new template called simple_contact_form.php will be created in your site/templates directory. Once created you can/should modify the template as well as the fields to your own needs, just make sure to maintain the names of the fields. So you can substitute the list (<ul> <li>..) tags with divs or adapt your css and set "list-style: none;" for this list.

To hide the fields adapt the css using for example "display: none;".

2) The action is not empty. action="./" refers to the current page. Have a look at your log file (Admin > Setup > Logs > simplecontactform-log). I guess the spam protection applies here and redirects you to the home page.

----------------------------------------------------

PS: These are simple basics of CSS and HTML.  ^_^ 

  • Like 1
Link to comment
Share on other sites

Hi,

Thanks for your reply. 

Please have a look at my contact page : http://pesisirbrand.com/contact/

After filling up the contact form and press submit button the browser return the Home page but data never got submitted

to inbox here : http://pesisirbrand.com/scf-messages/

Admin > Setup > Logs > simplecontactform-log returned :

 

[FAILURE] Honeypot field was filled.

Link to comment
Share on other sites

The field you named "Web Url (Optional)" is not allowed to be filled. This field should be invisible. Spam boots are used to fill every field and the honey pot technique is one way to keep them out. Hide this field, add one field more to get a web url field if needed.

Link to comment
Share on other sites

Thanks justb3a,

It works. 

I tried adding 3 more input fields into the form (Address, Telephone Number & Identification) and then created 3 new fields in the admin section but where can I define the input id ( e.g : Inputfield_Alamat ) for those 3 new form fields ?

Here are things that I've done so far ..

simple_contact_form.php

<div class="form-group">
		<label class="col-md-3 control-label" for='Inputfield_Alamat'>Alamat<i class='toggle-icon fa fa-angle-down' data-to='fa-angle-down fa-angle-right'></i></label>
		<div class="col-md-9">

<input id="Inputfield_Alamat" class="form-control" name="Address" value="<?= $input->Alamat; ?>" type="text" maxlength="2048" placeholder="" />
		</div>
            </div>

site/modules/SimpleContactForm/SimpleContactForm.module

protected static $defaults = array(
    'fullName' => '',
    'Address' => '',
    'Telephone Number' => '',
    'Identification' => '',
    'emailTo' => '',
    'emailSubject' => 'New Web Contact Form Submission',
    'successMessage' => 'Thank you, your submission has been sent.',
    'errorMessage' => 'Please verify the data you have entered.',
    'emailMessage' => '',
    'emailServer' => 'noreply@server.com',
    'allFields' => 'fullName,Alamat,Telefon,KadPengenalan,email,message',
    'requiredFields' => 'fullName,Alamat,Telefon,KadPengenalan,email,message',
    'emailField' => 'email',
    'saveMessages' => true,
    'antiSpamTimeMin' => '0',
    'antiSpamTimeMax' => '90',
    'antiSpamPerDay' => '3',
    'antiSpamExcludeIps' => '127.0.0.1',
    'antiSpamCountAdditionalInputs' => '5',
    'useTwig' => false,
    'cleanup' => 0
  );

.....

.....

public static function getModuleConfigInputfields(array $data) {
    $fields = new InputfieldWrapper();
    $modules = wire('modules');

    // default config values
    $data = array_merge(self::$defaults, $data);

......
.......

     'Address' => array(
        'type' => 'InputfieldText',
        'description' => 'Fallback: Alamat',
        'size' => 45,
        'placeholder' => 'Alamat',
        'columnWidth' => 50
      ),
      'Telephone Number' => array(
        'type' => 'InputfieldText',
        'description' => 'Fallback: Telefon',
        'size' => 45,
        'placeholder' => 'Telefon',
        'columnWidth' => 50
      ),
      'Identification' => array(
        'type' => 'InputfieldText',
        'description' => 'Fallback: Kad Pengenalan',
        'size' => 45,
        'placeholder' => 'Kad pengenalan',
        'columnWidth' => 50
      ),
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...