I need to save a submitted form as a text file in a different folder than the submission form?
I have this form below i use at the moment which is working fine. But i want to save the form in a different folder like /submission/ for example.It should be the part $filename = but i got syntax error when i try to add a folder name there.
if (!file_exists(date('Ymd'))) {
mkdir(date('Ymd'), 0777, true);
}
if (!file_exists($username)) {
mkdir($username, 0777, true);
}
$filename = date('Ymd')."/" . $product . "-" .$username . ".txt";
$filename1 = $username."/" . date('YmdHis') . ".txt";
if (!file_exists($filename)) {
$fh = fopen($filename, 'w') or die("Can't create file");
}
$ret = file_put_contents($filename, $data, FILE_APPEND | LOCK_EX);
if($ret === false) {
die('There was an error writing this file');
}
else {
echo "Your Keywords And Urls Submitted";
}
if (!file_exists($filename1)) {
$fh = fopen($filename1, 'w') or die("Can't create file");
}
$ret = file_put_contents($filename1, $data, FILE_APPEND | LOCK_EX);
if($ret === false) {
die('There was an error writing this file');
}
else {
var_dump($producttmp['product_id']);
}
}
else {
die('no post data to process');
}