I have a html/php code as shown below which on click of a download button at Line Z downloads a php file. The drop-down list which I have from the select element is:
1. Hi
2. Hello
3. Good Morning
4. Good Evening
Let us suppose, I have selected Hi from the dropdown list. On hitting download button, php file (hi.php) belonging to Hi dropdown gets downloaded not executed.
<form method="get" action="fr_get.php">
<h1>Report</h1>
<select name="report">
<?php
foreach ($reports->getReports() as $report) {
$users = $report->getAll('AllowedUser'); ?>
<option value="<?= $report->path; ?>"><?= (is_array($users) && in_array('deleted',
$users) ? 'DELETED --- ' : '').$report->getFirst('Title'); ?></option>
<?php
}
?>
</select>
<div class="submit"><input type="submit" value="Download"/></div> // Line Z
</form>
The code inside fr_get.php is
<?php
$db = connect_mysql();
if (!is_admin()) {
die('Access Denied.');
}
$report = $_GET['report'];
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="'.basename($report).'"');
readfile($report);
Problem Statement:
I am wondering what changes I need to make in the php code above so that on click of Download button at Line Z, php file should get executed not downloaded.