在循环中的一个php内执行另一个php文件

I have a php code that has if statements(to export as pdf, to export as excel and the last one to upload excel).

The first two if's to upload pdf and excel are working fine, when I click on the button to run the the third if statement, it shows me blank page, even though the code for it is working fine when I run it separately.

My php code is below:

<?php
define('FPDF_FONTPATH','/Applications/XAMPP/xamppfiles/lib/php'); 
if (isset($_POST['pdf'])) {
     //code//
}
}
if (isset($_POST['excel'])) {
    //code//

}

if (isset($_POST['upload'])) {

exec( 'imp.php');

}
?>

The imp.php file which I am trying to run is:

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$db_host = 'localhost';
$db_user = 'root';
$db_pwd = '';

$database = 'mydatabase';
$table = 'demo';

if (!@mysql_connect($db_host, $db_user, $db_pwd))
    die("Can't connect to database");

if (!mysql_select_db($database))
    die("Can't select database");


    if(isset($_POST['submit']))
    {
         $fname = $_FILES['sel_file']['name'];
         echo 'upload file name: '.$fname.' ';
         $chk_ext = explode(".",$fname);

         if(strtolower(end($chk_ext)) == "csv")
         {

             $filename = $_FILES['sel_file']['tmp_name'];
             $handle = fopen($filename, "r");

             while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
             {
                $sql = "INSERT into demo(orders,quantity,country,dates,comment) values('$data[0]','$data[1]','$data[2]', '$data[3]','$data[4]')";
                mysql_query($sql) or die(mysql_error());
             }

             fclose($handle);
             echo "Successfully Imported";

         }
         else
         {
             echo "Invalid File";
         }   
    }

    ?>
    <h1>Import CSV file</h1>
    <form action='<?php echo $_SERVER["PHP_SELF"];?>' method='post' enctype="multipart/form-data">
        Import File : <input type='file' name='sel_file' size='20'>
        <input type='submit' name='submit' value='submit'>
    </form

exec function executes file on server. You won't see anything unless you explicitly get result of exec to a variable and output it.

But as I see - you just want to include some php file into another - for this are include and require are supposed:

include '/path/to/file.php';

This will be enough.