Jump to content

[HELP]Secure PHP connect to Mysql


rocker_angad

Recommended Posts

well i am very very new to mysql and php so after reading lots of tutorial the problem i am facing is to add or get data from mysql you have to put your username and password in the script in the php file for eg the code we use to connect is

 

mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error());

mysql_select_db("address") or die(mysql_error());

 

now the problem is anyone can view this page and see my username and password and hit me hard i am new dont flame me. IF this problem has already been solved please give me the link Of the forum

 

as i dont want everyone to see my username and password

Some one who is a professional or know how to do it please tell me, waiting for reply

 

THANK YOU

angad

Link to comment
Share on other sites

I have a file placed behind teh root of the site I require_once in any page requireing the connection. that way you only have to manage one file...

 

but in your case if you run your page and its showing the username and password details then it sounds like php is not running properly - none of your source code should be available to view in the browser when you run a page.  If it is doing then the installation has not been successful.

Link to comment
Share on other sites

Your FTP access should be setup with a username/password. Don't setup an anonymous FTP account for a folder that would contain any important files.

 

When you browse to a .php file, the code in it is parsed and executed and you only receive content that is output by that file. Unless you echo the host, username, and password, no one can get those details by visiting your site.

 

The http/https protocols don't allow downloading of files unless you explicitly cause a file to be downloaded.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.