Reputation: 9
I am using the default Opencart 2.0.3.1. Everything works great, except for the contact form. For some reason, it does not validate the form, and gives no errors after submitting. Any ideas? You can view it here: https://sgroiinnovations.com/index.php?route=information/contact
I can not figure it out. The same type of validation is used for entering a review, and it works correctly. In the contact form, when submit is clicked, it submits the form with no information entered. No errors are provided before or after the page is submitted.
In the contact.php, there is no question that it is calling the validate function below, but again for some reason, the submit button just seems to submit the page (form) without this process.
I'm guessing there is something simple that I am missing, but I can't catch it. Any help would be appreciated. Thx
protected function validate() {
if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 32)) {
$this->error['name'] = $this->language->get('error_name');
}
if (!preg_match('/^[^\@]+@.*.[a-z]{2,15}$/i', $this->request->post['email'])) {
$this->error['email'] = $this->language->get('error_email');
}
if ((utf8_strlen($this->request->post['enquiry']) < 10) || (utf8_strlen($this->request->post['enquiry']) > 3000)) {
$this->error['enquiry'] = $this->language->get('error_enquiry');
}
if ($this->config->get('config_google_captcha_status')) {
$recaptcha = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($this->config->get('config_google_captcha_secret')) . '&response=' . $this->request->post['g-recaptcha-response'] . '&remoteip=' . $this->request->server['REMOTE_ADDR']);
$recaptcha = json_decode($recaptcha, true);
if (!$recaptcha['success']) {
$this->error['captcha'] = $this->language->get('error_captcha');
}
}
return !$this->error;
}
Upvotes: 0
Views: 652
Reputation: 9
Problem fixed. The issue was that I was forwarding http to https using .htaccess. This blew up the contact form because of non-secure to secure. Not sure why, but I removed the redirect and it works.
Upvotes: 0