Jump to content

[SOLVED] mysql security fast question


asmith

Recommended Posts

i have add a line in mysql for a user like :

GRANT ALL On *.* to john@localhost IDENTIFIED BY "smith";

 

 

and in the "add user" page , i have

$connection = mysql_connect ("localhost","john","smith");

 

$sql= INSERT INTO table_name (username, password) values (....bla bla

mysql_query ($sql,$connection);

 

 

i wanted to know when i upload such file to my web site,

is there anyway for someone who could download these php codes ?

i mean in this file i have certainly said that there is a john with a password smith user for my mysql ,

so can anyone download my php code to find out this ?

Link to comment
Share on other sites

The best way I think is to define your connection in constant.php file and store it in separate folder not on the local directory and include that file in your adduser.php page

 

constant.php will have

 

<?php define ('SERVERHOST','localhost' );
define ('SERVERUSER','serveruser' );
define ('SERVERPASSWORD','yourpassword' );
define ('SERVERDATABASE','dbname' );
define ('LOCALRHOST','localhost' );
define ('LOCALUSER','root' );
define ('LOCALPASSWORD','' );
define ('LOCALDATABASE','localdb' );
// and use the connection like this 
$sLocalHost=LOCALRHOST;
$sServerHost=SERVERHOST;
$sLocalUser = LOCALUSER;
$sLocalPassword = LOCALPASSWORD;
$sServerUser = SERVERUSER;
$sServerPassword = SERVERPASSWORD;
$sServerDatabaseName = SERVERDATABASE;
$sLocalDatabaseName = LOCALDATABASE;
$conn = @mysql_connect($sServerHost,$sServerUser,$sServerPassword);
if(!$conn) {
$conn = mysql_connect($sLocalHost,$sLocalUser,$sLocalPassword);
}
//$con=  mysql_connect("localhost","root"); //On Local Server
$db=mysql_select_db($sServerDatabaseName);
if(!$db){
$db=mysql_select_db($sLocalDatabaseName);
}
//----------------------------------------//

if($conn=="")
{
  trigger_error('Unable to connect to database: ' . mysql_error());
}
?>

Then you can include your constat.php file in user.php file so you don't have to specify a connection each time

require_once("includes/constant.php"); 

Link to comment
Share on other sites

Until peoples have FTP access they cannot download the file normally. They may know the path and see in the browser but they won't see anything not even through view source  ;D for e.g if you have kept the constant.php file like this

http://www.mysite.com/mysitename/includes/constant.php

and if you see this file in the browser blank page will show up. But you must only keep php codes no table or tds.

 

 

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.