Code: Select all
<?php
if (isset($_POST['Submit']))
{
//variables
$fName=$_POST['fName'];
$lName=$_POST['lName'];
$email=$_POST['email'];
@ $fp=fopen("$dRoot//fopen//data//entries.txt",'ab');
if (!$fp)
{
echo "Couldn't open the file";
exit;
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL))
{
$fError&="Please write a proper email<br />";
$errorNumber=1;
}
if(strlen($fName)<6)
{
$fError&="Please write a proper email<br />";
$errorNumber=1;
}
if (!isset($errorNumber))
{
$fdata=$fName."\t".$lName."\t".$email."\t".date("d-m-Y")."\t".date("H-i-s")."\t"."\r\n";
fwrite($fp,$fdata,999);
}
else
{
echo $fError;
}
}
?>
The problem :
This code doesn't show any erros whatsoever.The problem is with "$fError&=" THAT I know. If I use "$fError=" instead than it works fine, but the problem is that in case of multiple errors it only shows one. Any solutions? Also if I run the code same as it is, it gives a warning saying $fError is undefined. Now if there IS no error than why is php interfering what's inside the if statment?