i think the biggest problem is that i have this code before any of the html code:
<?php
header ("Content-type: application/force-download");
header ("Content-Disposition: $attachment filename=Signuplist.txt");
?>
then later in there is an if statement used to verify a password. the file i want to automatically download is created by the code:
if ($vinepass==$passwd AND $passwd !=""){
$conn = mysql_connect("localhost", "username", "password");
$dbtxt = "database";
$querytxt = "SELECT * FROM testingsignups WHERE Band=\"$Band\"
AND showyear='$showyear' AND showmonth='$showmonth' AND showday='$showday'";
$rs = mysql_db_query($dbtxt,$querytxt,$conn);
$fp = fopen("$Band-$showyear-$showday-$showmonth.txt", "a");
while($myrow = mysql_fetch_array($rs))
{
$Name = $myrow["Name"];
$Street = $myrow["Street"];
$City = $myrow["City"];
$State = $myrow["State"];
$Zip = $myrow["Zip"];
$Email = $myrow["Email"];
$column = "$Name--$Street--$City--$State--$Zip--$Email\n";
$writefile = fputs($fp, $column);
}
fclose($fp);
and i only want the file to be downloaded if the if statement conditions are met. so after the above code i entered this code to download the file:
$size = filesize("$Band-$showyear-$showday-$showmonth.txt");
$fileData = fopen ("$Band-$showyear-$showday-$showmonth.txt", "r");
$str .= chop(fgets($fileData,$size))."\n<br>";
fpassthru ($fileData);
when the file is downloaded i don't get the contents of the file downloaded, i get the code of the next php script that is run.
any ideas on how to correct this problem??