Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with error messages

Status
Not open for further replies.

Zuggy

Programmer
May 18, 2007
12
US
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.

Code:

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?
 
Hi

[tt]$_POST['report_url'] == true[/tt]

Are you sure you will have a boolean true, or equivalent of it ? I do not think so, because usually the elements of [tt]$_POST[/tt] are strings.

[tt]$_FILES['uploaded_file'] == true[/tt]

Are you sure you will have a boolean true, or equivalent of it ? I do not think so, because usually the elements of [tt]$_FILES[/tt] are arrays.


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top