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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:03:55+00:00 2026-06-06T07:03:55+00:00

Ok , so many people are asking this question, and there are many approaches

  • 0

Ok , so many people are asking this question, and there are many approaches on how to make the connection to DB secure,

Now I did some googling , many suggest, putting the connection to DB code in a file outside the html_public , and to call it from there when I need to make a connection.

to be honest, am happy with what I have, though I’m not sure how secure it is,

this is how I connect to the DB:

first, I make sure all inputs are fully escaped and validated…

after , in the same page , i make the connection, for example:

mysql_connect("localhost","Admin","Password") or 
die ("DB Connection Error");
mysql_select_db("Users") or die ("DB Error");

and the rest of the code after, I close the mysql connection.

Now , It just don’t feel right that the DB user info are written in the page, but how can someone (a “hacker”) , get this info?

I mean , all inputs are fully escaped and validated, the users I use have very limited previleges, like select and update… only.

Is this secure?? and if not, can u please suggest a more secure way?

Thank you very much for ur help in advance 🙂

shady

  • 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-06T07:03:57+00:00Added an answer on June 6, 2026 at 7:03 am

    The reason you should consider putting this file outside the web root is that some hosting providers have temporarily stopped interpreting PHP from time to time (due to configuration faults, often after an update on their part). The code will then get sent in clear text and the password will be out in the wild.

    Consider this directory structure, where public_html is the web root:

    /include1.php
    /public_html/index.php
    /public_html/includes/include0.php
    

    Now consider this index.php:

    <?php
    include('includes/include0.php');
    do_db_work_and_serve_page_to_visitor();
    ?>
    

    If the web server starts serving this file in the open, it won’t take long before someone tries to download include0.php. Nobody will be able to download include1.php, however, because it’s outside the web root and therefore never handled by the web server.

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

Sidebar

Related Questions

There are many people asking questions related to this issue, but none are complete
I recently encountered this problem. I found many instances of people asking the question—
I have seen many people asking this question and have tried it all (such
There was a post this morning asking about how many people disable JavaScript. Then
In asking around and doing some research, it seems like many people are really
Edit Since there were many downvotes and people who didn't understand what I'm asking
There are many people asking questions on SO about how to get around the
I have scoured the net, and found many people asking this, yet none have
Many people use this method to add animation on switching views. When I try
Many people suggest to develop web applications in open source technologies. And one of

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.