Zuggy Posted June 25, 2007 Share Posted June 25, 2007 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 More sharing options...
Wildbug Posted June 25, 2007 Share Posted June 25, 2007 Check print_r($_POST), see what's being POSTed in each case, and write your if conditions to match. Don't guess. Link to comment https://forums.phpfreaks.com/topic/57084-erroneous-error-messages/#findComment-282092 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.