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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:27:25+00:00 2026-06-15T05:27:25+00:00

I’m working on a project that needs to have users log into a MySQL

  • 0

I’m working on a project that needs to have users log into a MySQL database. I’m working through making an authentication system(auth/user table with their names, email, hashed password etc, php session), its more work than I realized but am making my way through it. I’m a little confused on the initial connection to the database though. I’ve read to keep it outside of the document root for the site, which I can do, but not sure how to reference it. Here is what I was thinking:

Document root for site:

/var/www/public/example.com/public/ {index.html,css,img,etc}

Could I safely place the db_connect info here:

/var/www/public/example.com/private/ securephpfunctions.php

I’d then have one line in all my php files:

<?php
// include in all files that need to do stuff
require_once('examplecom_fns.php'); 
?>

Inside examplecom_fns.php is:

<?php
// include in all files
require_once('/var/www/public/example.com/private/securephpfunctions.php');
require_once('forms_fns.php');
require_once('outputs_fns.php');
?>

After this, I assume I can call my DB connect function to insert new users info into the DB, use for not signed in users searching public entires, etc. Is that correct/OK? Is there a better or more secure way to do what I’m trying? Am I way off base?

  • 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-15T05:27:26+00:00Added an answer on June 15, 2026 at 5:27 am

    You can reference your document root with the following:

    $_ENV['document_root'];
    

    Then, by adding a relative path, you can get your private path:

    realpath($_ENV['document_root'] . '../private');
    

    Then add to that the name of your private config file:

    realpath($_ENV['document_root'] . '../private/securephpfunctions.php');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a reasonable size flat file database of text documents mostly saved in
I am trying to loop through a bunch of documents I have to put

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.