alberto Posted October 25, 2018 Share Posted October 25, 2018 (edited) Hi to everybody, i just noted now that my contact form is not working, it keeps saying "An error occurred while sending the message, please try again..." INFO: PS version 1.7.3.3 Info server Linux #36-Ubuntu SMP Wed Aug 15 16:00:05 UTC 2018 x86_64 Version server: Apache Version PHP: 7.1.20 i thought it was a cloudflare problem, but then when i switched it off the error persisted. I checked the file: modules/contactform/contactform.php: the error is in the sendMessage() function and specifically in this else statement: elseif ($url !== '' || empty($serverToken) || $clientToken !== $serverToken || $clientTokenTTL < time() ) { /* error happen here */ $this->context->controller->errors[] = $this->trans( 'An error occurred while sending the message, please try again... ', [], 'Modules.Contactform.Shop' ); $this->createNewToken(); } i tried to print out the 4 variables but only $serverToken and $clientTokenTTL were printed. What could be the problem? I am NOT a prestashop developer, just another happy sometimes user. thank you in advance! Alberto Edited October 26, 2018 by alberto (see edit history) 1 Link to comment Share on other sites More sharing options...
Rolige Posted October 25, 2018 Share Posted October 25, 2018 Hello: According to your information it seems that you are not receiving properly the params on the submit: $url = Tools::getValue('url'); $clientToken = Tools::getValue('token'); Check in your browser developer console the request made when you click on Send message button and verify that parameters of the request are send successfully. If yes, in PHP try to print all $_POST and $_GET vars to check if "url" and "token" values are setted properly. If not, you should look in the HTML code if this vars exists in fact and have a valid value. That´s the first step. Good luck. Regards Link to comment Share on other sites More sharing options...
alberto Posted October 25, 2018 Author Share Posted October 25, 2018 36 minutes ago, Rolige said: Hello: According to your information it seems that you are not receiving properly the params on the submit: $url = Tools::getValue('url'); $clientToken = Tools::getValue('token'); Check in your browser developer console the request made when you click on Send message button and verify that parameters of the request are send successfully. If yes, in PHP try to print all $_POST and $_GET vars to check if "url" and "token" values are setted properly. If not, you should look in the HTML code if this vars exists in fact and have a valid value. That´s the first step. Good luck. Regards In the console i just see: id_contact: 2 from: <email> message: test submitMessage: Send I went through the contactform.tpl and i can see at the end there is: <style> input[name=url] { display: none !important; } </style> <input type="text" name="url" value=""/> <input type="hidden" name="token" value="{$token}" /> <button type="submit" name="submitMessage"> {l s='Send' d='Modules.Contactform.Shop'} </button> BUT if i look at the html page thos two fields are not present... and also the structure seems to be different.. why? This is all i have in the footer section of the contact form html page.. <input class="btn btn-primary" type="submit" name="submitMessage" value="Send"> Is that contactform.tpl being used or there is another one somewhere? I tried to uninstall and reinstall it, no change Link to comment Share on other sites More sharing options...
Rolige Posted October 25, 2018 Share Posted October 25, 2018 2 hours ago, alberto said: In the console i just see: id_contact: 2 from: <email> message: test submitMessage: Send I went through the contactform.tpl and i can see at the end there is: <style> input[name=url] { display: none !important; } </style> <input type="text" name="url" value=""/> <input type="hidden" name="token" value="{$token}" /> <button type="submit" name="submitMessage"> {l s='Send' d='Modules.Contactform.Shop'} </button> BUT if i look at the html page thos two fields are not present... and also the structure seems to be different.. why? This is all i have in the footer section of the contact form html page.. <input class="btn btn-primary" type="submit" name="submitMessage" value="Send"> Is that contactform.tpl being used or there is another one somewhere? I tried to uninstall and reinstall it, no change You maybe have another TPL in your installed theme overriding the default one. Look for it on theme folder. According to your code params are there, but according to your HTML they are not, so you are probably looking on the wrong TPL file. Regards 1 1 Link to comment Share on other sites More sharing options...
alberto Posted October 26, 2018 Author Share Posted October 26, 2018 (edited) 16 hours ago, Rolige said: You maybe have another TPL in your installed theme overriding the default one. Look for it on theme folder. According to your code params are there, but according to your HTML they are not, so you are probably looking on the wrong TPL file. Regards SOLVED. Thanks! there is another TPL file which is under "<theme folder>/modules/contactform/views/templates/widget/contactform.tpl" i just added the two rows: <input type="hidden" name="url" value=""/> <input type="hidden" name="token" value="{$token}"> just before the submit button, and it works! The strange thing was that editing the first tpl file, i was able to see modifications.. infact i printed the variables by doing so.. but actually the file under the theme folder is also involved... i am confused by that, seems that it takes both files.. Thanks! Edited October 26, 2018 by alberto (see edit history) 6 Link to comment Share on other sites More sharing options...
Rolige Posted October 26, 2018 Share Posted October 26, 2018 5 hours ago, alberto said: SOLVED. Thanks! there is another TPL file which is under "<theme folder>/modules/contactform/views/templates/widget/contactform.tpl" i just added the two rows: <input type="hidden" name="url" value=""/> <input type="hidden" name="token" value="{$token}"> just before the submit button, and it works! The strange thing was that editing the first tpl file, i was able to see modifications.. infact i printed the variables by doing so.. but actually the file under the theme folder is also involved... i am confused by that, seems that it takes both files.. Thanks! Please, mark question as solved Regards Link to comment Share on other sites More sharing options...
fernandido Posted January 9, 2019 Share Posted January 9, 2019 On 10/26/2018 at 11:10 AM, alberto said: SOLVED. Thanks! there is another TPL file which is under "<theme folder>/modules/contactform/views/templates/widget/contactform.tpl" i just added the two rows: <input type="hidden" name="url" value=""/> <input type="hidden" name="token" value="{$token}"> just before the submit button, and it works! The strange thing was that editing the first tpl file, i was able to see modifications.. infact i printed the variables by doing so.. but actually the file under the theme folder is also involved... i am confused by that, seems that it takes both files.. Thanks! Hello for everybody, I've added this lines : <input type="hidden" name="url" value=""/> <input type="hidden" name="token" value="{$token}"> and error message doesn't appear but it doesn't work because email never is recieved!. Any idea? I am stuck some days. Link to comment Share on other sites More sharing options...
Fabicii Posted February 13, 2019 Share Posted February 13, 2019 Hi! Prestashop version: 1.6.x Try this: root > controllers > front > Contact.Controller.php On line 56 aprox. comment out this lines as shown below: /* } elseif ($url === false || !empty($url) || $saveContactKey != (Tools::getValue('contactKey'))) { $this->errors[] = Tools::displayError('An error occurred while sending the message.'); */ It WORKED for me after 1000 tries ... and I tried EVERYTHING!!! GOOD LUCK Link to comment Share on other sites More sharing options...
arissafety Posted March 5, 2019 Share Posted March 5, 2019 On 10/26/2018 at 4:10 PM, alberto said: <input type="hidden" name="url" value=""/> <input type="hidden" name="token" value="{$token}"> nice, my contact form is working now.. thanks a lot Link to comment Share on other sites More sharing options...
MarioH Posted April 3, 2019 Share Posted April 3, 2019 Thank you your steps and some overrides helped me too Link to comment Share on other sites More sharing options...
Web HvD Posted April 29, 2019 Share Posted April 29, 2019 Nice, it is working now. Thanks a lot. Link to comment Share on other sites More sharing options...
solostyle Posted May 2, 2019 Share Posted May 2, 2019 hello, I have the same problem under prestashop 1.7.4.3 I do not know what to do someone can help me Link to comment Share on other sites More sharing options...
Fabicii Posted May 8, 2019 Share Posted May 8, 2019 @solostyle can you provide me the link to you store? then I might figure it out what the problem is. Link to comment Share on other sites More sharing options...
mozed1 Posted May 20, 2019 Share Posted May 20, 2019 @Alberto Thanks! Solved my problem! Link to comment Share on other sites More sharing options...
Kriter.io Posted June 7, 2019 Share Posted June 7, 2019 prestashop 1.7.4.1 ...unfortunately it does not work. here is the link: SITE any suggestion or help? Link to comment Share on other sites More sharing options...
Gavimse Posted July 17, 2019 Share Posted July 17, 2019 falabby you fixed the issu, how did you do it? Link to comment Share on other sites More sharing options...
c.cristinziano Posted September 16, 2019 Share Posted September 16, 2019 On 1/9/2019 at 11:48 AM, fernandido said: Hello for everybody, I've added this lines : <input type="hidden" name="url" value=""/> <input type="hidden" name="token" value="{$token}"> and error message doesn't appear but it doesn't work because email never is recieved!. Any idea? I am stuck some days. I have the same problem, because I don't see the error message anymore, but I still don't receive emails... Can someone help me? thanks a lot Link to comment Share on other sites More sharing options...
fernandido Posted October 12, 2019 Share Posted October 12, 2019 Cristinziano, I updated last contactform module and it worked. Link to comment Share on other sites More sharing options...
crash11 Posted September 14, 2020 Share Posted September 14, 2020 (edited) I have the same problem, it shows me the message "An error occurred while sending the message." I received the message on Back Office, but I dont receive the email. I use 1.7.6.4 Edited September 14, 2020 by crash11 (see edit history) Link to comment Share on other sites More sharing options...
fernandido Posted September 14, 2020 Share Posted September 14, 2020 Please, try to update contactform module. It worked to me Link to comment Share on other sites More sharing options...
crash11 Posted September 14, 2020 Share Posted September 14, 2020 I did it, but not worked. Link to comment Share on other sites More sharing options...
yousaf traders Posted October 7, 2020 Share Posted October 7, 2020 Hello My name is saboor and i need help from modrator.Right know i am facing some problems on pristashop and its making headache for me.I am trying to Upgrade Pristashop but its giving Request time out by the server and i need some one who can guide me to the right path. Link to comment Share on other sites More sharing options...
Kriter.io Posted October 7, 2020 Share Posted October 7, 2020 1 hour ago, yousaf traders said: Hello My name is saboor and i need help from modrator.Right know i am facing some problems on pristashop and its making headache for me.I am trying to Upgrade Pristashop but its giving Request time out by the server and i need some one who can guide me to the right path. 1 hour ago, yousaf traders said: Hello My name is saboor and i need help from modrator.Right know i am facing some problems on pristashop and its making headache for me.I am trying to Upgrade Pristashop but its giving Request time out by the server and i need some one who can guide me to the right path. Hello, i would suggest you to upgrade your hosting profile. It is a matter related to your hosting profile and hosting company. Link to comment Share on other sites More sharing options...
Oktay Posted June 19, 2021 Share Posted June 19, 2021 Thanks, I solved my same problem with this topic. </div> </section> <footer class="form-footer text-xs-right"> <input type="hidden" name="url" value=""/> <input type="hidden" name="token" value="{$token}"> <input class="btn btn-primary" type="submit" name="submitMessage" value="{l s='Send' d='Shop.Theme.Actions'}"> </footer> </form> </section> 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now