Jump to content

Erroneous error messages


Zuggy

Recommended Posts

I'm trying to write a script that allows people to either upload a file or add a link to the database. I don't want it to do both, but I can't seem to get my error messages right. Here's the code for my messages.

 

if (!$_POST['report_url'] && !$_FILES['uploaded_file']){
die('You did not complete all of the required fields, <a href="addreport.php">Return</a>');
}
if ($_POST['report_url'] == true && $_FILES['uploaded_file'] == true){
die('You can only upload a report OR post a link to a report, not both, <a href="addreport.php">Return</a>');
}
if (isset($_FILES['uploaded_file'])){
if(!$_FILES['uploaded_file']['error'] == 0);
die('there was a problem with your upload');
}

 

I think what's happening is that $_FILES is set regardless of whether or not I put anything into the corresponding input box, because if I don't put anything in either box it skips to error 3 and it I put something into only report_url it fires off error 2. Is this the problem and if so how do I fix it?

Link to comment
https://forums.phpfreaks.com/topic/57084-erroneous-error-messages/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.