Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8573829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:20:23+00:00 2026-06-11T19:20:23+00:00

I’m having a little issue with some php logic in my main index page,

  • 0

I’m having a little issue with some php logic in my main index page, that will include certain pages based on the results of some functions, mainly to do with login/logout and the first time a user logs in after registering. The php that manages the includes is below:

UPDATE: (Based on suggestions from @arjan and @bigman I’ve updated the code as follows. The end result is still the same).

<?php
if ($login->checkForRegisterPage()) {
    include("views/pages/home.php");
// are we logged in ?
} elseif ($login->isLoggedIn()) {

    // check whether account is activated
    if (!$login->checkActivated()) {
        include("views/pages/activate.php");

    // check whether user has logged in before
    } elseif ($login->checkFirstLogin()) {
        include("views/pages/build_profile.php");

    // check action in URL and redirect accordingly
    } elseif ($checkaction->checkForBuildProfilePage()) {
        include("views/pages/build_profile.php");
    } elseif ($checkaction->checkForViewProfilePage()) {
        include("views/pages/profile.php");

    // if all else fails, load the dashboard
    } else {
        include("views/pages/dashboard.php");
    }
} else {

    // not logged in, showing the login form
    include("views/pages/home.php");
}
?>

The problem is with the two functions $login->checkActivated(); and $login->checkFirstLogin(); included below:

public function checkFirstLogin() {
  $checkfirstlogin = $this->db->query("SELECT first_login FROM users WHERE first_login = 'Y' AND user_name = '".$this->user_name."';");

  if($checkfirstlogin->num_rows == 1) {
    return true;
  } else {
    return false;
  }
}


public function checkActivated() {
  $checkactivated = $this->db->query("SELECT activated FROM users WHERE activated = 'N' AND user_name = '".$this->user_name."';");

  if($checkactivated->num_rows == 1) {
    return false;
  } else {
    return true;
  }
}

When the user first logs in, these functions return the correct result and I receive the page that I want. However, after login, I can still click and travel to other links on the page e.g. checkForViewProfilePage(); looks for view=profile in the URL. The thing is in order for the logic to reach the point where it even checks for that, it would have had to get past the two functions checkActivate(); and checkFirstLogin();, which it shouldn’t be able to do while those criteria are met, but it still can. I hope I’m making sense. Can anyone see an error?

Obviously my login form calls the Login class which the awkward functions are stored in, and so this would be loaded on login, but the class is included in the same way here so I’m not sure why the functions don’t appear to be firing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:20:25+00:00Added an answer on June 11, 2026 at 7:20 pm

    I solved it. The problem was higher up in the Login class – in Login db connections are only created when a session_start() is fired, i.e. on first login. Created a new class with db connection launched with each function and everything worked as it was.

    Thanks to @arjan and @bigman for the formatting tips r.e. nesting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.