I can't seem to find the folder called invoice and not sure whether my code is correct or not
I tried to change the write to write and read but it still hasn't created the file in the folder for me...
$invoice = "------------------------------------\n";
$invoice .= "Level 1 Monthly Subscriptionplan Information\n";
$invoice .= $level1."\n";
$invoice .= "Subscriptionplan:".$row['subscriptionplan']."\n";
$invoice .= "Enrollment Date:".$row['subscriptionplandate']."\n";
$invoice .= "Monthly Fees:".$row['feesmonthly']."\n";
$invoice .= "Payment Status:".$row['paid']."\n";
$invoice .= "Expiry Date:".$row['expirydate']."\n";
$invoice .= "Payment Due Date:".$row['paidbydate']."\n";
$myfile='invoice/level1monthly/'.$_SESSION['u_uid'].'.txt';
$fh = fopen($myfile, 'w+') or die("can't open file");
fwrite($fh, $invoice);
fclose($fh);
I expect it to create a folder called invoice in my root directory of my live server
Level 3 Monthly Subscriptionplan Information Subscriptionplan: Enrollment Date: Monthly Fees:0 Payment Status: Expiry Date: Payment Due Date:
I have done the following code but can't get it to change to append
$invoice .= "Level 1 Monthly Subscriptionplan Information\n";
$invoice .= $level1."\n";
$invoice .= "Subscriptionplan:".$row['subscriptionplan']."\n";
$invoice .= "Enrollment Date:".$row['subscriptionplandate']."\n";
$invoice .= "Monthly Fees:".$row['feesmonthly']."\n";
$invoice .= "Payment Status:".$row['paid']."\n";
$invoice .= "Expiry Date:".$row['expirydate']."\n";
$invoice .= "Payment Due Date:".$row['paidbydate']."\n";
$myfile='invoice/level1monthly'.$_SESSION['u_uid'].'.txt';
$fh = fopen($myfile, 'a+') or die("can't open file");
fwrite($fh, $invoice);
fclose($fh);
} else {
$invoice = "------------------------------------\n";
$invoice .= "Level 1 Monthly Subscriptionplan Information\n";
$invoice .= $level1."\n";
$invoice .= "Subscriptionplan:".$row['subscriptionplan']."\n";
$invoice .= "Enrollment Date:".$row['subscriptionplandate']."\n";
$invoice .= "Monthly Fees:".$row['feesmonthly']."\n";
$invoice .= "Payment Status:".$row['paid']."\n";
$invoice .= "Expiry Date:".$row['expirydate']."\n";
$invoice .= "Payment Due Date:".$row['paidbydate']."\n";
$myfile='invoice/level1monthly'.$_SESSION['u_uid'].'.txt';
$fh = fopen($myfile, 'w+') or die("can't open file");
fwrite($fh, $invoice);
fclose($fh);
}
This is my updated code... Will this work in terms of creating a new file if it doesn't exist and then append it?
$myfile='invoice/level1monthly'.$_SESSION['u_uid'].'.txt';
if(file_exists($myfile)) {
$invoice = "------------------------------------\n";
$invoice .= "Level 1 Monthly Subscriptionplan Information\n";
$invoice .= $level1."\n";
$invoice .= "Subscriptionplan:".$row['subscriptionplan']."\n";
$invoice .= "Enrollment Date:".$row['subscriptionplandate']."\n";
$invoice .= "Monthly Fees:".$row['feesmonthly']."\n";
$invoice .= "Payment Status:".$row['paid']."\n";
$invoice .= "Expiry Date:".$row['expirydate']."\n";
$invoice .= "Payment Due Date:".$row['paidbydate']."\n";
$fh = fopen($myfile, 'a+') or die("can't open file");
fwrite($fh, $invoice);
fclose($fh);
} else {
$invoice = "------------------------------------\n";
$invoice .= "Level 1 Monthly Subscriptionplan Information\n";
$invoice .= $level1."\n";
$invoice .= "Subscriptionplan:".$row['subscriptionplan']."\n";
$invoice .= "Enrollment Date:".$row['subscriptionplandate']."\n";
$invoice .= "Monthly Fees:".$row['feesmonthly']."\n";
$invoice .= "Payment Status:".$row['paid']."\n";
$invoice .= "Expiry Date:".$row['expirydate']."\n";
$invoice .= "Payment Due Date:".$row['paidbydate']."\n";
$myfile='invoice/level1monthly'.$_SESSION['u_uid'].'.txt';
$fh = fopen($myfile, 'w+') or die("can't open file");
fwrite($fh, $invoice);
fclose($fh);
}