0

我的脚本在 localhost WampServer 1st 上运行,它在那里工作,然后将其导出到我的在线实时域。经过一些调整后,我让脚本再次部分工作,但我仍然低于错误

Call to undefined function filter_var()

此脚本的目的是当用户想要注册时,它将验证电子邮件地址并将用户添加到数据库中,并向用户电子邮件地址发送验证链接。

这是脚本:

<?PHP
error_reporting(E_ALL);
ini_set('display_errors', 1);
// connection towards database with a include function
include ('connection.php');

if (isset($_REQUEST['send']))
{
    if(isset($_REQUEST['NAAM']))
    {
        $naam = $_REQUEST['NAAM'];
    }

    function spamcheck($field)
    {
        //filter_var() sanitizes the e-mail
        //address using FILTER_SANITIZE_EMAIL
        $field = filter_var($field, FILTER_SANITIZE_EMAIL);

        //filter_var() validates the e-mail
        //address using FILTER_VALIDATE_EMAIL
        if(filter_var($field, FILTER_VALIDATE_EMAIL))
        {
            return TRUE;
        }else
        {
            return FALSE;
        }
    }

    //if "email" is filled out, proceed
    if (isset($_REQUEST['mail']))
    {

        //check if the email address is invalid
        $mailCheck = spamcheck($_REQUEST['mail']);
        if ($mailCheck == TRUE)
        {
            $email = $_REQUEST['mail'];
        }else
        {
            $mailCheck = FALSE;
            echo "Invalid input email";
        }
    }

    if(isset($_REQUEST['question']))
    {
        $quest = $_REQUEST['question'];
        // checks if the filled in Question is de same as the answer novice or Novice
        if ($quest =="novice" or $quest =="Novice")
        {
            $questCheck = TRUE;
        }else
        {
            $questCheck = FALSE;
            echo "Your answer to the question was incorrect!<br>";
        }
    }

    if(isset($_REQUEST['wachtwoord'] , $_REQUEST['c_wachtwoord']))
    {

        $WW = $_REQUEST['wachtwoord'];
        $c_WW = $_REQUEST['c_wachtwoord'];

        // checks if the filled in password is de same as the confirmation password
        if ($WW == $c_WW)
        {
            $pwCheck = TRUE;
        }else
        {
            $pwCheck = FALSE;
            echo "Your filled in passwords are not the same try again!<BR>";
        }
    }       



    // checks if both password confirmation and question are TRUE continue else retrieve fault
    if ($pwCheck && $questCheck && $mailCheck == TRUE)
    {
        $hash = md5( rand(0,1000) );
        // insert all filled in values into the database
        $opdracht1 = "INSERT INTO users (ID , name , password , mail , staffLevel , hash , active) VALUES ('','$naam','$WW','$email','0','$hash','0')";

        // run query 
        if (mysql_query ($opdracht1))
        {
            header( "refresh:5;url=http://www.debeerislos.nl/inlog_user.php" );
            echo "Your account has succesfully been created! Please check your email to validate your account!<BR>";

                    $to      = $email; //Send email to our user
                    $subject = 'Signup | Verification'; //// Give the email a subject 
                    $message = '

                    Thanks for signing up!
                    Your account has been created!
                    You can login with the following credentials:

                    ------------------------
                    Username: '.$naam.'
                    Password: '.$WW.'
                    ------------------------

                    After you have activated your account you will have the rights so you can fully use it.

                    Please click this link to activate your account:
                    http://www.debeerislos.nl/verify_user.php?email='.$email.'&hash='.$hash.'&name='.$naam.'

                    '; // Our message above including the link

                    $headers = 'From:info@debeerislos.nl' . "\r\n"; // Set from headers
                    mail($to, $subject, $message, $headers); // Send the email

        }else
        {
            echo "Woops something went wrong please contact the Administrator of the website or fill in the form again!<br> <A href='http://www.debeerislos.nl/form_register_user.html'>CLICK HERE!</A> to fill in the forum again";
        }
    }elseif ($pwCheck && $questCheck == FALSE)
    {
        echo "you filled both the password confirmation and the answer to the question incorrect!<br>";
    }       
}else
{
    echo "Either you haven't send anything! or you haven't filled in the form<br>";
}
?>

提前谢谢你。

亲切的问候, StaleDevil

4

1 回答 1

0

你在哪里定义了filter_var()功能?它没有在您给定的代码中定义。如果您在同一页面中定义它,那么您是如何定义的?举个例子。否则,如果您在另一个页面中定义它,则包含该页面。

于 2013-06-14T08:09:05.167 回答