Skip to content

ACM eventYear page blank page routing bug fixed#356

Open
Siddharth-Pushkar wants to merge 3 commits intodevelopfrom
sp/routingerror
Open

ACM eventYear page blank page routing bug fixed#356
Siddharth-Pushkar wants to merge 3 commits intodevelopfrom
sp/routingerror

Conversation

@Siddharth-Pushkar
Copy link
Copy Markdown
Collaborator

@Siddharth-Pushkar Siddharth-Pushkar commented Jan 21, 2024

eventYear page routing bug fixed.

I shifted the whole header code out of the html tag because it was interfering with header.php.

In the original page header code,
$year = $_GET["year"];
only got the year from the database and did not specify what to do if it was empty.

it is replaced with,
$year = isset($_GET["year"]) ? $_GET["year"] : 2023;
this line decides whether there is a year parameter in the header or not, if not then it will be 2023.

then made an array validyears and added all the years when the events took place
then added an ' if ' statement to check whether the header has a valid year or not.
if it exceeds the valid year, the user will be redirected to the default 2023.
In the future, if there are more event years, we can just add more years and update the default header to the latest year.
$validYears = [2019, 2020, 2021, 2022, 2023];
if (!in_array($year, $validYears)) {
header("Location: eventYear.php?year=2023");
exit();
}

the previous code for this is still there, just commented
during my testing, it didn't affect anything.

22 Jan Commit

Kept this at the top to check whether there is ' year ' or not, if not it will redirect you to the latest year events
if (!isset($_GET["year"])) {
header("Location: eventYear.php?year=2023");
exit();
}

$year = $_GET["year"];
now to get the year for the header

then rest is the same
$validYears = [2019, 2020, 2021, 2022, 2023];
if (!in_array($year, $validYears)) {
// Handle invalid year (you can redirect to a default year or display an error)
header("Location: eventYear.php?year=2023");
exit();
}

@anur4ag anur4ag removed the request for review from harshgoyal7065 January 23, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants