I am trying to get the following information to be written into a text file and can get it to work in my cPanel but not with VConnect. Have you guys used VConnect before?
I have tried changing the folder's name and have already set the permission to write in my folder called invoice but still can't get it to write in the folder.. everything else is working but just creating the file...
<?php
include_once 'navbar.php';
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
if(!isset($_SESSION['u_uid'])) {
header("Location: index.php?medical_subscriptionplan_process=notlogin");
exit();
} else {
include_once 'includes/dbh.php';
if(isset($_POST['submit'])) {
$views = strip_tags($_POST['subscriptionplan']);
$csrf = strip_tags($_POST['token']);
if (!hash_equals($csrf, $_SESSION['token'])) {
header("Location: medical_subscriptionplan.php?medical_subscriptionplan_process=wrongtoken");
exit();
} else {
if ($views == '') {
header("Location: medical_subscriptionplan.php?medical_subscriptionplan_process=emptied");
exit();
} else {
if ($views == '10_views') {
$subscriptionplan = '10_views';
$views = 10;
$token = 'qqewreqreqwsdfdfdafcbvcQERFGHFGHGFHRETERTDF!@#$%^^()';
$token = str_shuffle($token);
$token = substr($token, 0, 10);
$date = date("Y-m-d H:i:s");
$paidbydate = date("Y-m-d H:i:s", strtotime("+2 day"));
$fees = 5;
$sql = "UPDATE memberships
SET subscriptionplan = ?, fees = ?, token = ?, enrollment_date = ?, paidbydate = ?, views = ?
WHERE user_uid = ?;
";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "sisssis", $subscriptionplan, $fees, $token, $date, $paidbydate, $views, $_SESSION['u_uid']);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$row = mysqli_fetch_assoc($result);
echo $row['subscriptionplan'];
echo $row['enrollment_date'];
$myfile='invoice/10views'.$_SESSION['u_uid'].'.txt';
if(file_exists($myfile)) {
$invoice = "------------------------------------
";
$invoice .= "Level 1 Monthly Subscriptionplan Information
";
$invoice .= $level1."
";
$invoice .= "Subscriptionplan:".$row['subscriptionplan']."
";
$invoice .= "Enrollment Date:".$row['enrollment_date']."
";
$invoice .= "Fees:".$row['fees']."
";
$invoice .= "Payment Status:".$row['paid']."
";
$invoice .= "Expiry Date:".$row['expirydate']."
";
$invoice .= "Payment Due Date:".$row['paidbydate']."
";
$fh = fopen($myfile, 'a+') or die("can't open file");
fwrite($fh, $invoice);
fclose($fh);
} else {
$invoice = "------------------------------------
";
$invoice .= "Level 1 Monthly Subscriptionplan Information
";
$invoice .= $level1."
";
$invoice .= "Subscriptionplan:".$row['subscriptionplan']."
";
$invoice .= "Enrollment Date:".$row['enrollment_date']."
";
$invoice .= "Monthly Fees:".$row['fees']. "AUD
";
$invoice .= "Payment Status:".$row['paid']."
";
$invoice .= "Expiry Date:".$row['expirydate']."
";
$invoice .= "Payment Due Date:".$row['paidbydate']."
";
$myfile='invoice/10views'.$_SESSION['u_uid'].'.txt';
$fh = fopen($myfile, 'w+') or die("can't open file");
fwrite($fh, $invoice);
fclose($fh);
}
// header("Location: medical_subscriptionplan.php?medical_subscriptionplan_process_10views=success");
}
} else {
if ($views == '100_views') {
$subscriptionplan = '100_views';
$views = '100 views';
$token = 'qqewreqreqwsdfdfdafcbvcQERFGHFGHGFHRETERTDF!@#$%^^()';
$token = str_shuffle($token);
$token = substr($token, 0, 10);
$date = date("Y-m-d: H:i:s");
$paidbydate = date('Y-m-d H:i:s', strtotime("+2 day"));
$fees = 50;
$sql3 = "UPDATE memberships
SET subscriptionplan = ?, fees = ?, token = ?, enrollment_date = ?, paidbydate = ?, views = ?
WHERE user_uid = ?;
";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql3)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "sisssis", $subscriptionplan, $fees, $token, $date, $paidbydate, $views, $_SESSION['u_uid']);
mysqli_stmt_execute($stmt);
$premium = 1;
$sql4 = "UPDATE users
SET premium = ?
WHERE user_uid = ?
";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql4)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "is", $premium, $_SESSION['u_uid']);
mysqli_stmt_execute($stmt);
header("Location: medical_subscriptionplan.php?medical_subscriptionplan_process_100views=success");
}
}
} else {
if ($views == 'unlimited') {
$subscriptionplan = 'unlimited';
$views = -1;
$token = 'qqewreqreqwsdfdfdafcbvcQERFGHFGHGFHRETERTDF!@#$%^^()';
$token = str_shuffle($token);
$token = substr($token, 0, 10);
$date = date("Y-m-d H:i:s");
$paidbydate = date('Y-m-d H:i:s', strtotime("+2 day"));
$fees = 500;
$sql5 = "UPDATE memberships
SET subscriptionplan = ?, fees = ?, token = ?, enrollment_date = ?, paidbydate = ?, views = ?
WHERE user_uid = ?;
";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql5)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "sisssis", $subscriptionplan, $fees, $token, $date, $paidbydate, $views, $_SESSION['u_uid']);
mysqli_stmt_execute($stmt);
$premium = 1;
$sql6 = "UPDATE users
SET premium = ?
WHERE user_uid = ?
";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql6)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "is", $premium, $_SESSION['u_uid']);
mysqli_stmt_execute($stmt);
header("Location: medical_subscriptionplan.php?medical_subscriptionplan_process_unlimited_views=success");
}
}
}
}
}
}
}
}
}
/*
} else {
if ($views == '100_views') {
$subscriptionplan = '100_views';
$views = '100 views';
$token = 'qqewreqreqwsdfdfdafcbvcQERFGHFGHGFHRETERTDF!@#$%^^()';
$token = str_shuffle($token);
$token = substr($token, 0, 10);
$date = date("Y-m-d: H:i:s");
$paidbydate = date('Y-m-d H:i:s', strtotime("+2 day"));
$fees = 50;
$sql3 = "UPDATE memberships
SET subscriptionplan = ?, fees = ?, token = ?, enrollment_date = ?, paidbydate = ?, views = ?
WHERE user_uid = ?;
";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql3)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "sisssis", $subscriptionplan, $fees, $token, $date, $paidbydate, $views, $_SESSION['u_uid']);
mysqli_stmt_execute($stmt);
$premium = 1;
$sql4 = "UPDATE users
SET premium = ?
WHERE user_uid = ?
";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql4)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "is", $premium, $_SESSION['u_uid']);
mysqli_stmt_execute($stmt);
} else {
if ($views == 'unlimited') {
$subscriptionplan = 'unlimited';
$views = -1;
$token = 'qqewreqreqwsdfdfdafcbvcQERFGHFGHGFHRETERTDF!@#$%^^()';
$token = str_shuffle($token);
$token = substr($token, 0, 10);
$date = date("Y-m-d H:i:s");
$paidbydate = date('Y-m-d H:i:s', strtotime("+2 day"));
$fees = 500;
$sql5 = "UPDATE memberships
SET subscriptionplan = ?, fees = ?, token = ?, enrollment_date = ?, paidbydate = ?, views = ?
WHERE user_uid = ?;
";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql5)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "sisssis", $subscriptionplan, $fees, $token, $date, $paidbydate, $views, $_SESSION['u_uid']);
mysqli_stmt_execute($stmt);
$premium = 1;
$sql6 = "UPDATE users
SET premium = ?
WHERE user_uid = ?
";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql6)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "is", $premium, $_SESSION['u_uid']);
mysqli_stmt_execute($stmt);
}
}
}
}
}
}
}
}
}
}
}
header("Location: index.php?medical_subscriptionplan_process=sucess");
}
}
}
}
}
This is my updated code and everything is working with the database but I am trying to use $row here and got a boolean given error. If I don't use the $row variable, then it is fine....