如果文件不存在但没有重定向,我正在尝试在新页面中进行重定向,但如果我只写警报,那么它正在工作。请帮我。
//php code
<?PHP
if(isset($_POST["bills"]))
{
if($_POST[month]=='Select Month' || $_POST[year]=='Select Year'){$msg="Please select valid month or year";}
else if(file_exists($path.$_POST["month"].$_POST["year"].'.pdf')){header('location:'.$path.$_POST[month].$_POST[year].'.pdf');}
else{?>
<script type='text/javascript' language="javascript">document.getElementById('downloadlink').click();</script>
<?PHP }
}
?>
//html code
<form action="electricitybills.php" method="post" >
<select name="year">
<?PHP include('include/billsyear.php'); ?>
</select>
<select name="month">
<?PHP include('include/billsmonth.php'); ?>
</select>
<div class="gobutton"><input type="submit" name="bills" value="GO"></div>
</form>
</div>
<br><br><br><a id="downloadlink" href="http://www.google.com" target="_blank" style="display:none;">link text</a></form>