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 9191967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:48:53+00:00 2026-06-17T20:48:53+00:00

I have followed MVC Pattern In my PHP pages. I have created a controller

  • 0

I have followed MVC Pattern In my PHP pages. I have created a controller page for every view page and which will interact with Model page. I have checked the Login of the User on the Top of the every View page. But I have Never checked in Controller page. Since It is possible to anyone enter directly to controller page and may change database content.

So anyone please tell me, is it possible to enter into database through controller page. And whether I need to check Login of the User in controller page.

  • 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-17T20:48:54+00:00Added an answer on June 17, 2026 at 8:48 pm

    If I understand correctly, you are putting a LOGIN check at the top of every linked page from your controller page (assuming your index.php).

    If so, then you don’t need to do a login check at the top of every one of your linked pages, only from the index.php. If your login succeeds at the top of your index.php, then you continue on to include your destined view page.

    For example (in your index.php)

    <?php
    
    if ( !$user->checkSession() )
        header('Location: login.php');
    
    if ( $_GET['p'] == 'viewPageName' )
        include('modules/viewPageName.php' )
    elseif and so on
    
    ?>
    

    EDIT

    Now I have a better understanding of your question.

    Solution 1:
    In your index.php (place at top)

    <?php
    define('DIRECT', true);
    
    your login check, etc...
    ?>
    

    In your other files, put at the top

    <?php
    if (!defined('DIRECT')) die('No direct access is allowed');
    
    other code, etc...
    ?>
    

    Solution 2:
    Put an .htaccess file in the folder where all your other files are located, and deny direct access to those files.

    Put in the .htaccess the following:

    deny from all
    

    Solution 3:
    Well, assuming you’ve defined the $db file at the index.php and have set the class up in your index.php, your other files will return errors because you didn’t define your DB class in them.

    In other words, if you defined $db = new Database(); in your index.php, your other files will get an error if you try to access directly because $db has yet to be defined in them.

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

Sidebar

Related Questions

I have followed this nice video tutorial to create a mini MVC PHP framework.
I have followed this guide: http://maven.apache.org/guides/plugin/guide-java-plugin-development.html I have created a maven-plugin project hello-maven-plugin with
I have followed this tutorial which allowed me to create a Silverlight DataGrid that
I have built an ASP.NET MVC 3 web application (with exlusively Razor/cshtml pages) that
I am using Spring MVC 3.0 for file upload, I have followed several online
I have an MVC 2.0 application that I'm playing around with in VS2010 which
I have a Spring MVC Controller in a very XML-slimmed application, we use a
Scenario: I have a page which contains a dropdownlist and a table which contains
I am new in Asp.net MVC.i have created mvc application using datasource but i
I followed this Saving Many to Many relationship data on MVC Create view This

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.