I have almost got my website working but just a bit stuck with my final if statement and according to php manual, I can do something like this…
In this instance, the 'else if' is a shorthand/inline else statement (no curly braces) with the if statement as a body. It is the same things as:
<?php
if($var == 'Whatever') {
} else {
if($var == 'Something Else') {
}
}
I guess I am missing some brackets or braces at the end but just can’t work out where exactly…
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<?php
session_start();
if(!isset($_SESSION['u_uid'])) {
header("Location: index.php?notlevel1user");
exit();
} else {
include_once 'includes/dbh.php';
$sql = "SELECT subscriptionplan, subscriptionplan2, subscriptionplan3, subscriptionplandate, subscriptionplandate2, subscriptionplandate3, fees, fees2, fees3, totalfees, paid, paid2, paid3, expirydate, expirydate2, expirydate3, paidbydate, paidbydate2, paidbydate3, emailreminder, emailreminder2, emailreminder3, overdue, overdue2, overdue3, activate, activate2, activate3 FROM memberships WHERE user_uid = ?";
// Create a prepared statement
$stmt = mysqli_stmt_init($conn);
//Prepare the prepared stement
if (!mysqli_stmt_prepare($stmt, $sql)) {
echo "SQL statement failed";
} else {
//Bind parameters to the placeholder
mysqli_stmt_bind_param($stmt, "s", $_SESSION['u_uid']);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $subscriptionplan, $subscriptionplan2, $subscriptionplan3, $subscriptionplandate, $subscriptionplandate2, $subscriptionplandate3, $fees, $fees2, $fees3, $totalfees, $paid, $paid2, $paid3, $expirydate, $expirydate2, $expirydate3, $paidbydate, $paidbydate2, $paidbydate3, $emailreminder, $emailreminder2, $emailreminder3, $overdue, $overdue2, $overdue3, $activate, $activate2, $activate3);
while(mysqli_stmt_fetch($stmt)) {
if ($subscriptionplan !== 'None' && $activate == 0) {
header("Location: index.php?level1=notactivated");
exit();
} else {
if ($subscriptionplan === 'Level 1' && date("Y-m-d") > $paidbydate && $activate == 1) {
$sql = "UPDATE memberships
SET paidbydate = now() + interval '2' day, emailreminder = 1, overdue = 1
WHERE user_uid = ?;
";
$stmt = mysqli_stmt_init($conn);
//Prepare the prepared stement
if (!mysqli_stmt_prepare($stmt, $sql)) {
echo "SQL statement failed";
} else {
//Bind parameters to the placeholder
mysqli_stmt_bind_param($stmt, "s", $_SESSION['u_uid']);
mysqli_stmt_execute($stmt);
header("Location: index.php?level1=overdue");
if($subscriptionplan === 'Level 1' && date("Y-m-d") > $paidbydate && $activate == 1 && $emailreminder == 1) {
$sql = "UPDATE memberships
SET subscriptionplan = '', paidbydate = '', expirydate = '', fees = '', totalfees = '', emailreminder = 0, activate = 0, overdue = 0, paid = ''
WHERE user_uid = ?;
";
$stmt = mysqli_stmt_init($conn);
//Prepare the prepared stement
if (!mysqli_stmt_prepare($stmt, $sql)) {
echo "SQL statement failed";
} else {
//Bind parameters to the placeholder
mysqli_stmt_bind_param($stmt, "s", $_SESSION['u_uid']);
mysqli_stmt_execute($stmt);
header("Location: index.php?level1=cancel");
if ($subscriptionplan === 'Level 1' && date("Y-m-d") < $paidbydate && $paid == 1 && $activate == 1) {
header("Location: level1videos.php");
exit();
} else {
header("Location: index.php?level1=error");
exit();
}
}
}
}
}
}
}
}
}