Redirecting after fopen()
Posted: Fri Jun 05, 2009 12:51 am
Okay, so I have a form that POSTs to itself and uses fopen to create a csv named after the person and save it on the local machine. It all works fine and the file is rendered perfectly. My only problem, and i'm probably just dumb, is that when it's done, I can't get it to redirect via the header or via the form action to the next page. It just goes to itself and is blank. Any idea? Here's the code:
Also, any shot in the dark there is a way to create and save the file on an absolute pathname relative to the OS? (i.e. ) Something crazy like that? (just dreaming)
Code: Select all
<?php
$f = addslashes($_POST['firstname']);
$m = addslashes($_POST['middlename']);
$l = addslashes($_POST['lastname']);
date_default_timezone_set ("America/Chicago");
$d = date("mdY-Hi");
$_SESSION['clinician'] = $f.$m.$l."_".$d;
session_start();
$first = addslashes($_POST['contact_first']);
$middle = addslashes($_POST['contact_middle']);
$last = addslashes($_POST['contact_last']);
$_SESSION['patient'] = $first.$middle.$last."_".$d;
if(isset($_POST['Submit'])){
$name = ''.$_POST['contact_first'].''.$_POST['contact_middle'].''.$_POST['contact_last'].''.date('mdY-Hi').'';
$filename = "formfiles/".$name.".csv";
$csv_output = '"'.$_POST['missed_aptDate'].'","'.$_POST['missed_aptTime'].'","'.$_POST['missed_aptTimeAMPM'].'","'.$_POST['missed_therapyType'].'","'.$_POST['missed_comments'].'"';
$name = '"'.$_POST['contact_first'].''.$_POST['contact_middle'].''.$_POST['contact_last'].''.date('mdY-Hi').'"';
$handle = fopen($filename, 'w+');
fwrite($handle, $csv_output);
fclose($handle);
exit;
set_msg('Contact Updated');
$redirect = "sigcapture/missedvisit/employee/capture.php";
header('Location: '.$redirect); die;
}
?>Code: Select all
$filename = "C:\formfiles\".$name.".csv";