Contact form is not working

12 replies · opened Jan 28, 2023

Gg163264Jan 28, 2023

Hi there,
My webpage was built using an older version of canvas (I'm currently waiting for the new version to rebuild the site).
I'm using contact form since long time (2-3 years) but since some months ago and without any modification in the code, it suddenly stopped working, the form don't disappear after the user click in SEND button (ENVIAR MENSAJE) and also I don't receive any email from it.
I am not sure if I should update the php code of the page or if it could be a bug somewhere in the javascript.
In both cases please provide me the instructions to fix it.

Thanks in advance.

Best Regards,

SSemicolon WebSTAFFJan 28, 2023

Hello,

Since your Form File: include/form.php (https://perutoursinfo.com/include/sendemail-es.php) is returning a 500 Internal Server Error, it is an indication that this is a Server Configuration issue.

Please consider adding the .customjs Class to the .form-widget DIV and then the following code at the very top of your include/form.php File just after the opening php tags:
[ch_pre type="php"]error_reporting(E_ALL);[/ch_pre]

which should display all the possible errors. Please notify us about the Error Message you see, after going through the process above, so that we can provide you with further assistance on this. Thanks for your Patience.

Meanwhile, do let us know if we can help you with anything else or if you find any further issues with Canvas.

Gg163264Jan 28, 2023

Since my form is based in an example from old canvas I don't have .form-widget ... the equivalent for this 2019 version is .contact-widget , I added .customjs there, also I add the ERROR line in sendemail-es.php as suggested ... you can see both changes in the provided images, but I'm not sure where to watch for the errors, because as you can see the modal still doesn't disappear and also I don't get any error messages.

Gg163264Jan 29, 2023

Hello again ... I just wanted to let you know that my page is based in Canvas 5.4 (or very close to it version) and I'm using a code similar to contact-5.html sample.

Gg163264Jan 29, 2023

Hello. I am running a second line of tests trying to fix this problem. Based on previous support responses to other customers (with similar problems), where you suggest to update the phpmailer and some functions, I have created a copy of the main html and copies of the php and js libraries, and I have followed a few steps which I will detail below:

  1. The copy html file for this second test is in the following path www.perutoursinfo.com/index-test.html
  2. This file was modified and now the form is processed using include/form.php (from version 6.6.5) I tried to use my original form code (sample contact-5.html from version 5.4) with only some minor changes. I basically added .customjs .form-widget .form-result (it looks like JS files search for those in the code but I'm not sure if they should be used in this way or if I should remove the other classes) and change the reference to functions.js to functions2.js (more info in number 5)

``

                
              
                
                    
                        
                            
                                Contáctenos llenando el siguiente formulario:
                                ×
                            
                            

                                
                                    
                                    

                                        

                                        
                                            Nombre / Apellidos *
                                            
                                        

                                        
                                            Email *
                                            
                                        

                                        

                                        
                                            Teléfono *
                                            
                                        

                                        
                                            Destino de viaje   
                                            
                                        

                                        

                                        
                                            Fecha de viaje
                                            
                                        

                                        
                                            # de Adultos
                                            
                                                -- Seleccione --
                                                1
                                                2
                                                3
                                                4
                                                5
                                                Más de 5
                                            
                                        

                                        
                                            # de Niños
                                            
                                                -- Seleccione --
                                                0
                                                1
                                                2
                                                3
                                                4
                                                5
                                                Más de 5
                                            
                                        

                                        

                                        
                                            Asunto *
                                            
                                        

                                        
                                            Mensaje *
                                            
                                        

                                        
                                            
                                        

                                        
                                            Enviar Mensaje
                                        

                                        

                                    

                                

                            
                            
                                Cerrar
                            
                        
                    
                
                
        

I basically
3. form.php file was modified in the receiver's email and sender's email part also I modified this part of code

require 'phpmailer/src2/Exception.php';
require 'phpmailer/src2/PHPMailer.php';
require 'phpmailer/src2/SMTP.php';
  1. From version 6.6.5 I have obtained the phpmailer/src folder and copied it as phpmailer/src2 (File: Exception.php, OAuth.php
    OAuthTokenProvider.php, PHPMailer.php, POP3.php, SMTP.php)
  2. I created a copy of function.js file (from version 5.4) renamed it as functions2.js and replaced some parts taken from version 6.6.5
    5a) I included SEMICOLON.widget.ajaxForm() in init: funcion() part
    5b) I addded ajaxForm: funtion() in functions2.js
		ajaxForm: function( element ){
			let formSettings = {
				element: element,
				default: '.form-widget',
				file: 'plugins.form.js',
				error: 'plugins.form.js: Plugin could not be loaded',
				execfn: false,
				pluginfn: () => $().validate && $().ajaxSubmit,
				class: 'has-plugin-form'
			};

			let settings = {
				element: element,
				default: '.form-widget',
				file: 'plugins.ajaxform.js',
				error: 'plugins.ajaxform.js: Plugin could not be loaded',
				execfn: 'SEMICOLON_ajaxFormInit',
				pluginfn: () => typeof scwAjaxFormPlugin !== "undefined",
				trigger: 'pluginAjaxFormReady',
				class: 'has-plugin-ajaxform'
			};

			SEMICOLON.initialize.functions( formSettings );
			SEMICOLON.initialize.functions( settings );
		},
  1. I copied files: plugins.ajaxform.js and plugins.form.js from version 6.6.5 to JS folder

with all these changes the form seems to work (I receive emails with the test data I used) but the message of successful submission or error is no longer displayed in the same page as before (in the top right corner there was a message with green or red background and white letters depending on the result of the submission) but it is displayed in a new tab in the form.php path (look at the attached screenshot)

Please let me know if I'm missing something in the code, or any suggestions to improve it and fix it.

Thanks in advance.

Regards.

SSemicolon WebSTAFFJan 31, 2023

Hello,

Thanks for your Patience!

Based on your reply, you appear to be doing partial upgrades which is not supported and highly discouraged as there will be conflicts in the codes. We highly recommend using Codes from the same version of Canvas. Since you are using Canvas v5.x, we recommend upgrading to Canvas v5.9.1 which you can download here: https://docs.semicolonweb.com/docs/changelog/version-5-9-1/ as it includes the form.php and the JS Codes required to run it, in the js/functions.js File. Also, this would not be a very lengthy file upgrade from the previous version you are running currently. Canvas v5 to v6 requires a lot of changes and we will be releasing v7 shortly which will again require many changes. So we highly recommend upgrading to the latest v5.9.1 and everything should work fine.

Additionally, we currently only provide Support for Canvas Versions that are less than one year old. So currently only Canvas v6.x is supported as v5.x is more than 2.5 years old. So while we can guide you on this Support Ticket, the changes and modifications must be done by you manually.

Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

Gg163264Jan 31, 2023

Hello again.
Thanks you for your response.

As suggested I updated components from version 5.4 to version 5.9.1

  • include folder
  • include/phpmailer folder
  • css folder
  • js folder

Also in version 5.6 changelog there are some modifications to forms that I included in my code.

*All the Templates with Forms
Code Updated Forms (except Subscription Forms) updated with New Codes:
Replaced .contact-widget and .quick-contact-widget CLasses with .form-widget Class
Replaced .contact-form-result and .quick-contact-form-result CLasses with .form-result Class
Add a Hidden Input to Forms with name="prefix" Attribute

``

form-es.php is a copy of form.php, with the the same functionality but using translated to spanish success/error messages.

As result of these changes:

  1. I'm receiving the email from contact web form
  2. But the user still being redirected to form-es.php with the success sent notification as you can see in the image

In addition to the above, I would be grateful if you could help me with these points:

a) In previous I modified php file to be able to receive from customers messages with spanish language characters like áéñí
$mail->CharSet = "UTF-8";
before doing the same change could you tell me if there is another way to do the same (maybe a parameter or any other modification)
b) How do I force validation for required fields before the content is sent?

Gg163264Jan 31, 2023

Just a clarification for my previous message.

For point 2. ... when the form was working as soon as the user clicked in SENT button ... in the upper right part a floating message appeared with a green or red background (depending if there was an error or not) with the result message. This message disappeared after a few seconds but the user stay in the same page.

SSemicolon WebSTAFFFeb 3, 2023

Hello,

Thanks for your Kind Patience!

  1. Regarding the Form redirecting to the include/form-es.php Page, this appears to be an issue with the JS Error on the Page. Please provide us with a Live URL with all the Updates Codes until v5.9.1 you have made to your website so that we can check and determine the cause of this issue. Then we can provide you with further assistance and fixes.

  2. The Code: $mail->CharSet = "UTF-8"; will still work fine for encoding special characters.

  3. This again appears to an issue with a JS Conflict on the Page, as the Form Validation is enabled by default. Check latest v5.9.1 example here: https://themes.semicolonweb.com/html/canvas/v5/contact.html .

Simply provide us with a Live URL so that we can check out the exact issue and provide you with more accurate assistance on this. Thanks for your Patience.

Meanwhile, do let us know if we can help you with anything else or if you find any further issues with Canvas.

Gg163264Feb 3, 2023

Hello,
Live URL is https://www.perutoursinfo.com

I already checked my site again comparing to the URL with contact form provided by you and my code is similar with different fields but with required fields like the prefix and botcheck also in the same place as your example.

SSemicolon WebSTAFFFeb 3, 2023

Hello,

We have just checked this out and your Form appears to be working perfectly fine. Check the video attached. Consider clearing your Browser Cache and check your website again.

Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

Gg163264Feb 3, 2023

I cleared my browser cache and now the notification seems to work just as you showed in your video.
Thank you for your time and quick response.

SSemicolon WebSTAFFFeb 3, 2023

Hello,

Glad the issue was resolved.

Do let us know if we can help you with anything else or if you find any further issues with Canvas.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard