Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-25-2010, 03:14 AM   PM User | #1
lexjoshua
New Coder

 
Join Date: Aug 2010
Location: Philippines
Posts: 15
Thanks: 6
Thanked 0 Times in 0 Posts
lexjoshua is an unknown quantity at this point
Exclamation Help on security!

Good day to all,

First my purpose is to share my database connection to someone (other server) but I want to restrict them from modifying it. It is just for viewing data not for modifying.

Code:
/*this is my php file that I wanted to share wherein the database connection can be found.
it's name for example is conn.php*/

mysql_connect('localhost,root,rootpassword');
mysql_select_db('db_database');
Now that I have my conn.php containing the sensitive part of my database including a password. This is the php file from another server that I want to share my conn.php to.

Code:
/*this is my php file from another server that will use my conn.php.
it's name for example is client.php*/

include 'http://www.mysite.com/conn.php';

$viewrecord = mysql_query("select * from record where id = 'myname'");

while ($result = mysql_fetch_array($viewrecord))
{
   echo $result['name'];
}
Now, we have settled the connection, and the client can view now the record from table record.
What I'm afraid of is, What if the client.php did something like:

Code:
include 'http://www.mysite.com/conn.php';

$name = "I will";
$age = "destroy the hell";
$address = "out of your database hahaha";

mysql_query("update record (name,age,address) values ('$name','$age','$address') where id = 'myname'");
Man that will be the worse day of my database if he did something like that, please advice me of some of security techniques.

Thanks!
lexjoshua is offline   Reply With Quote
Old 08-25-2010, 03:32 AM   PM User | #2
xanderman
New Coder

 
Join Date: May 2006
Location: Pennsylvania, USA
Posts: 31
Thanks: 0
Thanked 4 Times in 4 Posts
xanderman is an unknown quantity at this point
create a new DB user for your client, give them acces to READ your database only.

Then any INSERT UPDATE and DELETE commands will be ignored.

In addition, including your config php from a remote site, as it uses "localhost" for the hostname, will not work, you'll need to get the DNS/IP address for your SQL server and use that. In addition some hosts only allow connections to the database from inside their datacenters, so they maynot beable to connect like that.

In that case, you'll need to create some sort of gateway.
xanderman is offline   Reply With Quote
Users who have thanked xanderman for this post:
lexjoshua (08-25-2010)
Old 08-25-2010, 04:49 AM   PM User | #3
lexjoshua
New Coder

 
Join Date: Aug 2010
Location: Philippines
Posts: 15
Thanks: 6
Thanked 0 Times in 0 Posts
lexjoshua is an unknown quantity at this point
I'll try it. Thanks!
lexjoshua is offline   Reply With Quote
Reply

Bookmarks

Tags
security, sql

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:46 AM.


Advertisement
Log in to turn off these ads.