Skip to content

Commit

Permalink
Fix bug: Restrict access to login and signup pages for logged-in users
Browse files Browse the repository at this point in the history
  • Loading branch information
Moslihbadr committed Jun 11, 2023
1 parent e23a718 commit 3a66b6c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion blog_details.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@
}else {
$login_user_id = NULL;
}

// check if the logged-in user is the blog owner or an admin
if ($login_user_id === $user_id) {
$show_delete_button = true;
}

// check if the user is an admin
$user_type = '';
if (isset($_COOKIE['login_user_id'])) {
$sql = "SELECT * FROM users WHERE user_id='$login_user_id' ";
Expand Down
6 changes: 6 additions & 0 deletions login.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?php
include("./php/connect_DB.php");

session_start();
// check if the user is logged in
if (isset($_COOKIE['login_user_id'])) {
header('location: index.php');
}


$errorMessage = "";

Expand Down
6 changes: 6 additions & 0 deletions signup.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?php
include('./php/connect_DB.php');

session_start();
// check if the user is logged in
if (isset($_COOKIE['login_user_id'])) {
header('location: index.php');
}

if (isset($_POST['signup'])){

$first_name = $_POST['fname'];
Expand Down

0 comments on commit 3a66b6c

Please sign in to comment.