0

在我的网站上,我有一个联系我们的表格,在我升级到 php 7 之前,它曾经可以正常工作。现在,当我填写表格时,它会作为无效电子邮件返回,并且日志不会显示任何错误。

早些时候它显示错误为

PHP Fatal error:  Uncaught Error: Call to undefined function eregi() in /app/index.php:27

这是第 27 行:

 if (!empty($email) && !preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
        $err[] = "Invalid email<br>";
    }

所以我改为eregipreg_match现在它不起作用。

<?php
$err=array();

if(count($_POST) > 0)
{

    $name = isset($_REQUEST["name"]) ? trim($_REQUEST["name"]) : "";
    $address = isset($_REQUEST["subject"]) ? trim($_REQUEST["subject"]) : "";
    $country = isset($_REQUEST["country"]) ? trim($_REQUEST["country"]) : "";
    $email = isset($_REQUEST["email"]) ? trim($_REQUEST["email"]) : "";
    $contact_no = isset($_REQUEST["contact_no"]) ? trim($_REQUEST["contact_no"]) : "";
    $budget = isset($_REQUEST["budget"]) ? trim($_REQUEST["budget"]) : "";
    $com_name = isset($_REQUEST["com_name"]) ? trim($_REQUEST["com_name"]) : "";
    $message_text = isset($_REQUEST["message_text"]) ? trim(addslashes($_REQUEST["message_text"])) : "";
    $message_text=htmlentities($message_text,ENT_QUOTES);


    $ipaddress = $_SERVER['REMOTE_ADDR'];
    $date = date("F j, Y, g:i a"); 


    if(empty($name)) $err[]="You must enter your name,";
    if(empty($email)) $err[]="proper email address,";

    if (!empty($email) && !preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
        $err[] = "Invalid email<br>";
    }
    if(empty($contact_no)) $err[]="proper contact no";

    if(!empty($contact_no) && !(is_numeric($contact_no)) )
    $err[]="Contact No must be in Number<br>";
4

0 回答 0