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

  • Home
  • SEARCH
  • 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 6176567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:07:26+00:00 2026-05-24T00:07:26+00:00

This is my first post here so apologies if the setup is kind of

  • 0

This is my first post here so apologies if the setup is kind of scrambled.

I am in the middle of working on an article database with MySQL and PHP.

I have a page which will show all articles by authors. I am trying to have a link at the top of the page redirect with a few PHP if statements so the user will have to log in if not already. If the user is already logged in (I haven’t a PHP script for adding users to database yet, working on it) the redirect will load a form to submit a new article.

Controller (index.php) :

<?php
include_once $_SERVER['DOCUMENT_ROOT'] .
        '/includes/magicquotes.inc.php';
require_once $_SERVER['DOCUMENT_ROOT'] . 
        '/includes/access.inc.php';

if (isset($_GET['add']))
  if (!userIsLoggedIn())
{
      include '/Test/articles/login.html.php';
      exit();
}
  else
{
      include 'form.html.php';
      exit();
}
                        :::PHP code left out for sake of example:::
include 'articles.html.php';
?>

access.inc.php contains SESSION() and $sql enrty scripts for entering and retaining username/passwords

userIsLoggedIn() is a function in access.inc.php (self explanatory)

login.html.php is my login form

form.html.php is the actual form to submit new articles

articles.html.php is the page which displays all of the articles in my database

My problem is that when I implement the if statement for the link to redirect to my login form when the user has not already logged in, I get PHP warnings when clicked which I don’t get because my paths are correct for /Test/articles/login.html.php and I’m unsure what to do about it.

Warnings :

Warning: include(/Test/articles/login.html.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\Test\articles\index.php on line 10

Warning: include() [function.include]: Failed opening '/Test/articles/login.html.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\Test\articles\index.php on line 10

Help please? I’m at a total loss.

  • 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-05-24T00:07:26+00:00Added an answer on May 24, 2026 at 12:07 am

    $_SERVER['DOCUMENT_ROOT'] is almost never a good choice when it comes to determining folder structure because its unreliable.

    Use dirname(__FILE__) instead.

    if (!defined('DS')) {
        define('DS', DIRECTORY_SEPARATOR);
    }
    define('APP_FOLDER', dirname(__FILE__) . DS);
    
        include_once APP_FOLDER . 'includes/magicquotes.inc.php';
        require_once APP_FOLDER . 'includes/access.inc.php';
    
    if (isset($_GET['addjoke']))
      if (!userIsLoggedIn())
    {
          include APP_FOLDER . 'Test/articles/login.html.php';
          exit();
    }
      else
    {
          include APP_FOLDER . 'form.html.php';
          exit();
    }
    

    BTW, your real mistake was that you included a slash before Test (/Test/...) indicating that you want to access a folder residing on a root level of the web server.

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

Sidebar

Related Questions

first post here and hopefully relevant to many people. I'm working on writing integration
I'm currently working on a database which is rather complex, at least for my
I'm trying to set up Jekyll so that a quote from the first post
I've come across some C++ code that looks like this (simplified for this post):
I have this function int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
I apologize for this, and I am sure it's a very rookie question... but
Greetings all, First of all thank you all for helping me out with my
I have the next code: $(document).ready(function () { $('#imgone').hide().delay(500).fadeIn(1000).delay(4500).fadeOut(500); $('#imgtwo').hide().delay(1500).fadeIn(1000).delay(3500).fadeOut(500); $('#imgthree').hide().delay(2500).fadeIn(1000).delay(2500).fadeOut(500); }); It's more
I'm trying to dynamically bind mysql_stmt parameters and get the result in an associative
I'm trying to write application for Android to access Google Tasks. I decided to

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.