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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:42:28+00:00 2026-05-27T22:42:28+00:00

I have a jQuery script using .live() to load it’s page content. $(‘#content’).load(content.php? +

  • 0

I have a jQuery script using .live() to load it’s page content.

$('#content').load("content.php?" + id);

Question: How can I deny a user from accessing the file content.php directly via a URL?

I tried to put this code on top of content.php but Access Denied appear in my #content div

if (!empty($_SERVER['SCRIPT_FILENAME']) && 'content.php' == basename($_SERVER['SCRIPT_FILENAME']))
    die('Access Denied');

What is the correct way to make sure users can’t access my content.php file using a URL?

  • 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-27T22:42:28+00:00Added an answer on May 27, 2026 at 10:42 pm

    You could use some sort of hashing. For example if content.php has the parameter id; you add an additional parameter hash which contains the MD5 hash of “‘some random string’ + id*15”. In content.php you check if the hash & id match; if not access denied.

    The computation has to be done in PHP (not ajax) because the user must not know the hashing algprithmus.

    With this method the user can look up the source code and access the page directly but you can’t disallow that completly because the browser need to access the page to show it. But the user can’t access pages he hasn’t accessed through ajax before. You could use some headers (HTTP_X_REQUESTED_WITH) to prevent most internet users to access the page directly but experienced users will change the header and access it anyway.

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

Sidebar

Related Questions

I have created a dynamic list picker script using Jquery 1.3 and PHP that
I have a html page using a jQuery UI Button with some jQuery script
I have a PHP page with various forms I've been using jQuery to submit/verify
I have made a Web page using jquery and php where all files are
I have a toggle button using this code: <script> jQuery(document).ready(function(){ jQuery('#MyToggleSwitch').live('click', function(event) { jQuery('.ElementToHideAndShow').toggle('show');
I have a jquery-ajax function that sends data to a php script and the
I have two scripts running on the same page, one is the jQuery.hSlides.js script
I have a problem I am using jquery U.I tabs that load everything with
I have a webpage using jquery 1.42 The following 2 segments of code live
I'm using the following jQuery script to highlight a table row on mouseover. input.find(tr).live('mouseover

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.