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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.