Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP connection include



8:50 am on Feb 28, 2007 (gmt 0)

5+ Year Member

I'm still teaching myself PHP/MySQL and am gradually doing small things to make my coding more secure.

One major thing I have heard is that it is bad to have the MySQL connection details in the same folder as the website. I have a file called conz.php with password, user name details etc which I include in every page.

As I'd expect if I view the source of any of the resultant pages I don't see this info. Is there a way that someone can see this info?

Also I heard that if someone includes my webpages in theirs they can wreak havoc with my database. Wouldn't they need to know my table names etc to do that?


8:59 am on Feb 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

If you have access to mysql, you can run SHOW TABLES to get the names,

usually simple include will not work, as it will include already parsed file,
What you could additionally do is put the include file to another folder, and with .htaccess further restrict access to it.



9:18 am on Feb 28, 2007 (gmt 0)

5+ Year Member

Thanks. I had thought about htaccess, but wouldn't that require the password to be entered each time the page is viewed?


9:39 am on Feb 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

That's why I suggested you put just the include to another folder, eg.
and in includes/ put .htaccess

but the pages are not there, only main folder.
Then by
require_once ('includes/include.php');

it will not ask for password


1:36 pm on Feb 28, 2007 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

you can also keep the file above the webroot which makes it impossible to include without being on the same physical machine

Featured Threads

Hot Threads This Week

Hot Threads This Month