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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:19:03+00:00 2026-05-16T02:19:03+00:00

Is it possible to password protect a page without db access? I may have

  • 0

Is it possible to password protect a page without db access? I may have only few pages. But I should be able to change password and also save sessions etc. And I want a secure way as it’s for production site!

How is it to store in a config.php after md5:

 <?php
 username="admin"; 
 password="1a1dc91c907325c69271ddf0c944bc72";
 ?>

If this is a good idea, is there a way to restrict access to this php from only one script
called check.php or something?

  • 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-16T02:19:04+00:00Added an answer on May 16, 2026 at 2:19 am

    Sure, why not? You can use flat files in inaccessible directory (protected by .htaccess or out of the www root) and use that as a database.

    Here’s a simple login class I’ve whipped up:

    class SimpleLogin {
    
        private $users;
        private $db = './pass.txt';
    
        function __construct() {
            $data = file_get_contents($this->db);
    
            if (!$data) {
               die('Can\'t open db');
            } else {
                $this->users = unserialize($data);
            }
        }
    
        function save() {
            if (file_put_contents($this->db, serialize($this->users)) === false)
                die('Couldn\'t save data');
        }
    
        function authenticate($user, $password) {
            return $this->users[$user] == $this->hash($password);
        }
    
        function addUser($user, $password) {
            $this->users[$user] = $this->hash($password);
            $this->save();
        }
    
        function removeUser($user) {
            unset($this->users[$user]);
            $this->save();
        }
    
        function userExists($user) {
            return array_key_exists($user, $this->users);
        }
    
        function userList() {
            return array_keys($this->users);
        }
    
        // you can change the hash function and salt here
        function hash($password) {
            $salt = 'jafo2ijr02jfsau02!)U(jf';
            return sha1($password . $salt);
        }
    
    }
    

    NOTE: You really should turn off error reporting if you are going to use this in an actual server. This can be done by calling error_reporting() or by adding ‘@’ in front of file_get_contents and file_put_contents (ie: so it turns into @file_get_contents)

    Usage example: http://left4churr.com/login/

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

Sidebar

Related Questions

I have two ASP.NET pages: site.com/foo/bar.aspx that should be world accessible and site.com/foo/baz.aspx that
Is it possible to control the format of the password that is automatically generated
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Background : I have a asp.net webapplication project that should contain a public and
I have a classifieds website. I as an administrator need to be able to
Is it possible to store passwords on the local system (Windows XP) that can
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
Possible Duplicate: .NET - What’s the best way to implement a catch all exceptions

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.