-1

I am getting issues on the 4th line. Everyone time someone submits and email is a vaild entry I get this error

Fatal error: Uncaught Error: Call to undefined function eregi() in /homepages/29/d409157025/htdocs/contacts.php:31 Stack trace: #0 {main} thrown in /homepages/29/d409157025/htdocs/contacts.php on line 4

The form was working perfectly since I uploaded it, thats been over a year.

//Check to make sure sure that a valid email address is submitted
if(trim($_POST['email']) == '')  {
    $hasError = true;
} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
    $hasError = true;
} else {
    $email = trim($_POST['email']);
}

//Check to make sure comments were entered
if(trim($_POST['message']) == '') {
    $hasError = true;
} else {
    if(function_exists('stripslashes')) {
        $comments = stripslashes(trim($_POST['message']));
    } else {
        $comments = trim($_POST['message']);
    }
}

//If there is no error, send the email
if(!isset($hasError)) {
    $emailTo = 'info@roswellhistoriccottage.com, artem.alek@icloud.com'; //Put your own email address here
    $body = "Name: $name \n\nEmail: $email \n\nComments:\n $comments";
    $headers = 'From: RHC Website Information Request <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;

    mail($emailTo, $subject, $body, $headers);
    $emailSent = true;
}
Jeremy Harris
  • 24,318
  • 13
  • 79
  • 133

1 Answers1

1

The eregi() function is deprecated and was removed in PHP 7. It appears you or your host recently updated you to PHP 7.

To fix the issue, you need to change the code to use preg_match() instead.

Jeremy Harris
  • 24,318
  • 13
  • 79
  • 133