I have a problem with using the ‘not’ (!) condition.
At start I had this:
if( eregi(".php", $userfile_name) || eregi(".jsp", $userfile_name) )
{
echo ("Problem: File is a disallowed file type.”);
exit;
}
This is code to block PHP or JavaScript files from being uploaded – an it worked alright; the disallowed files produced an error message, and other files where allowed.
However I changed the code and it failed – I changed it to this:
if( !eregi(".zip", $userfile_name) || !eregi(".html", $userfile_name) )
{
echo ("Problem: File must be a zip file or a HTML file.”);
exit;
}
This time I want to only allow .zip files and HTML files. But it echoes the ‘Problem: File must be…’ even if the file is a .zip or .html
It also happens when I use forms – and check for blank fields using the isset() function.
if( !isset(‘$example_field’ )
{
echo(“Please fill out all required fields”);
}
This always echoes the message saying the field is blank – even if it isn’t..
I have read examples that use !isset() and I think it should work – what am I doing wrong?
I have also tried:
if( isset(‘$example_field’ == “false” )
#I’ve tried “false without quotes – and with single quotes but it doesn’t change anything
{
echo(“Please fill out all required fields”);
}
It still doesn’t work!
Any help would be extremely appreciated! 🙂