Form not sending, function eregi() is deprecated

Hey I am trying send my form, but I get this error…
Deprecated: Function eregi() is deprecated

I tried replacing it with preg_match(), but no luck. Here is my code…

Please let me know if you need to see more, thanks in advance!

$all_valid = $name_valid = $email_valid = $comments_valid = true;

if (isset($_POST['submit'])) {  

    if ($_POST['name'] == '') {
        $all_valid = $name_valid = false;
    }

    if ($_POST['comments'] == '') {
        $all_valid = $comments_valid = false;
    }

    if (!$validator->check_email_address($_POST['email'])) {
        $all_valid = $email_valid = false;
    }

    if ($all_valid) {
        //  ####    NO PROBLEMS FOUND - PROCESS THE FORM DATA HERE
        $mail_to = 'cat30@hotmail.com'; //  recipient address
        $subject = "Email from website";    //  email message subject line
        $name = mysql_real_escape_string(trim($_POST['name'])); //  sanitize the name
        if (eregi("\r",$name) || eregi("\n",$name)){    //  avoid email header injection
            die();
        }
        $mail_from = mysql_real_escape_string(trim($_POST['email']));   //  sanitize their email address
        if (eregi("\r",$mail_from) || eregi("\n",$mail_from)){  //  avoid email header injection
            die();
        }
        $comments = htmlspecialchars(trim($_POST['comments'])); //  convert HTML characters into entities

        $headers = 'From: '. $mail_from. "\r\n";
        mail($mail_to, $subject, $comments, $headers);

        $response = '<h2>Thanks for contacting us, will get back to you soon</h2>';
    }

}

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories