Linked Questions

Popular Questions

Jump to Another Page After Generate Excel File in PHP

Asked by At

I'm making a form (form.php) for user to insert data, after user finish inserting data, form action will jump to formGenerateXLS.php (using POST method) for generate user data to XSL file. In the bottom of formGenerateXLS.php I put a javascript code to jump to dashboard (home.php) but it fail. The Excel file successfully generate but javascript code not working. How to work with that?

   $product_desc = $_POST['product'];
   $filename_excel = date("Ymd_")."$product_desc";
   header("Content-type: application/vnd-ms-excel");
   header("Content-Disposition: attachment; filename=$filename_excel.xls");

   echo "<table border='1'>";
     echo "<tr>";
       echo "<th colspan='3' bgcolor='#1bf3b3'>New Ticket Request</th>";
     echo "</tr>";
     echo "<tr>";
        echo "<td>Name</td>";
        echo "<td></td>";
        echo "<td>User</td>";
     echo "</tr>";
    echo "</table>"

echo "<script>window.location='home.php'</script>";

Related Questions