Welcome to WebmasterWorld Guest from 50.17.114.227

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP connection include

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

New User

5+ Year Member

joined:Mar 22, 2006
posts:38
votes: 0


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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 26, 2003
posts:1133
votes: 0


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.

Regards
Michal

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

New User

5+ Year Member

joined:Mar 22, 2006
posts:38
votes: 0


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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 26, 2003
posts:1133
votes: 0


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

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

it will not ask for password
Michal

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

Administrator

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

joined:July 24, 2001
posts:15755
votes: 0


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