I have a link/button on my page that should lead the user to a csv file. The csv file is generated dynamically using PHP, based on some POST variables:
<?php
header("Content-type: application/csv");
header("Content-Disposition: attachment; filename=e".date('ymdHis').".csv");
...
?>
How can I redirect to the script, at the same time passing POST variables, without using a form?
Answers I found that I didn't really like:
You may use GET method - user won't see GET string (ugly URL), it won't be displayed in the new window. But if you really need POST (though i cannot even imagine why), you should create form with hidden fields - this is the only way to do your task (yes, i've tested many ways before saying this).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With