Php 如何处理此错误?
我已经让我的脚本在本地主机WampServer上运行,它在那里工作,然后将它导出到我的在线live域。 经过一些调整后,我让脚本再次正常工作,但我仍然得到以下错误Php 如何处理此错误?,php,user-registration,Php,User Registration,我已经让我的脚本在本地主机WampServer上运行,它在那里工作,然后将它导出到我的在线live域。 经过一些调整后,我让脚本再次正常工作,但我仍然得到以下错误 Call to undefined function filter_var() 此脚本的用途是,当用户想要注册时,它将验证电子邮件地址,并将用户添加到数据库,并向用户电子邮件地址发送验证链接 以下是脚本: <?PHP error_reporting(E_ALL); ini_set('display_errors', 1); /
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>";
}
?>
您在哪里定义了filter\u var()
函数?它未在给定代码中定义。如果在同一页中定义,那么如何定义?举个例子。否则,如果您要在另一个页面中定义它,请包含该页面。您有什么php版本?请检查您的php版本>=5.2这是PHP5.2+本机函数。请更仔细地阅读脚本就在这里函数spamcheck($field){//filter\u var()使用filter\u SANITIZE\u EMAIL$field=filter\u var($field,filter\u SANITIZE\u EMAIL);//filter\u var()使用filter\u VALIDATE\u EMAIL验证电子邮件//如果(过滤变量($field,filter\u VALIDATE\u EMAIL)){