Header and Form Action issue
Posted: Tue Jun 02, 2009 5:43 pm
Okay, this shouldn't be too hard...
Here in this example I am writing comma seperated $_POST values from the form to a .csv file created based on the record name:
The problem I have is that I can't figure out how to use the header to 1) Render the csv file with the data and 2) redirect to the next page. How can I redirect the page once the download box pops up? If I try to add the header redirect below, it says the header has already been assigned. I tried the but it overrides the csv creation in the header. Any way to do one and then the other?
Here in this example I am writing comma seperated $_POST values from the form to a .csv file created based on the record name:
Code: Select all
$csv_output = '"Appointment Time","Appointment Time 2","Appointment Date","Therapy Type","Comments"';
$csv_output .= "\n";
$csv_output .= '"'.$_POST['missed_aptTime'].'","'.$_POST['missed_aptTimeAMPM'].'","'.$_POST['missed_aptDate'].'","'.$_POST['missed_therapyType'].'","'.$_POST['missed_comments'].'"';
$csv_output .= "\n";
$name = '"'.$_POST['contact_first'].''.$_POST['contact_middle'].''.$_POST['contact_last'].''.date('mdY-Hi').'"';
f(isset($_POST['Submit'])){
//You cannot have the breaks in the same feed as the content.
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv; filename=$name.csv");
print $csv_output;
exit;
}Code: Select all
<form action="redirect_page.php">