PHP 7.0 and Contact form not works

April 2014 WordPress Theme
GK User
Fri Feb 17, 2017 1:51 pm
Hello, I have put the version of php 7.0 on the Hosting server and everything is fine except sending messages from the contact form of the home.
I've tried sending emails with the "Check Email" plugin with PHP 7.0 version and it works.
When I send a message through the contact form it does not send anything and leaves the screen blank. It is a problem of the contact form.
Could you help me?
Regards and thank you very much,
Joselu
User avatar
Fresh Boarder

Joshua M
Sun Feb 19, 2017 11:02 pm
Hi,

Try to edit template.contact.php file and change the following fragment:
Code: Select all
// check the e-mail
   if($params_email) {
      if(trim($_POST['email']) === '' || !eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
         $validated = false;
         $errors['email'] = __('please enter correct email address.', GKTPLNAME);
      } else {
         $output['email'] = trim($_POST['email']);
      }
   }


into:
Code: Select all
   // check the e-mail
   if($params_email) {
      $regex = '/([a-z0-9_]+|[a-z0-9_]+\.[a-z0-9_]+)@(([a-z0-9]|[a-z0-9]+\.[a-z0-9]+)+\.([a-z]{2,4}))/i';
      if(trim($_POST['email']) === '' || !preg_match($regex, trim($_POST['email']))) {
         $validated = false;
         $errors['email'] = __('please enter correct email address.', GKTPLNAME);
      } else {
         $output['email'] = trim($_POST['email']);
      }
   }
User avatar
Moderator


cron
Remember me
Register New Account
If you are old Gavick user, click HERE for steps to retrieve your account.