Go Back   CodingForums.com > :: Client side development > General web building

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 01-08-2011, 07:55 PM   PM User | #1
izecul
New Coder

 
Join Date: Jan 2011
Posts: 10
Thanks: 4
Thanked 0 Times in 0 Posts
izecul is an unknown quantity at this point
Lightbulb If I reveal a table/view, is it safe?

Hi,

How safe is it for my site if I pass a table or view name as an argument in the URL? (GET method) I would like to use a single AJAX handler (both JS and PHP) and do the parsing only from the main page.

If this is not safe, and if I have two different fields using AJAX, how do I make them use the same scripts but different tables?

Thanks.
izecul is offline   Reply With Quote
Old 01-08-2011, 08:36 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
It could be safe, but may pose SEO issues, if that's important to you.

Can you give us more of an example of what you mean?
mlseim is offline   Reply With Quote
Old 01-08-2011, 08:49 PM   PM User | #3
izecul
New Coder

 
Join Date: Jan 2011
Posts: 10
Thanks: 4
Thanked 0 Times in 0 Posts
izecul is an unknown quantity at this point
For instance, if I use:

AJAXHandler.php?table=tablename&args=arglist...

to handle my AJAX query, the table name is revealed to anyone using a developer's console (in Firefox 4, you can certainly see the URL for the AJAX request)

If this is unsafe, is there a way around it?
izecul is offline   Reply With Quote
Old 01-08-2011, 09:14 PM   PM User | #4
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Give your MySQL tables names like,
catalog_7643
users_7643
conguration_7643

Then, append the _7643 after you do the $_GET

They will only see half of the table name.
mlseim is offline   Reply With Quote
Users who have thanked mlseim for this post:
izecul (01-10-2011)
Old 01-08-2011, 09:22 PM   PM User | #5
bazz
Master Coder

 
Join Date: Apr 2003
Location: in my house
Posts: 5,211
Thanks: 39
Thanked 201 Times in 197 Posts
bazz will become famous soon enoughbazz will become famous soon enough
can you do it using the session?

store the values in the session and then when running AJAXhandler.php make it get those values from the session?

bazz
__________________
"The day you stop learning is the day you become obsolete"! - my late Dad.

Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
Useful MySQL resource
Useful MySQL link
bazz is offline   Reply With Quote
Users who have thanked bazz for this post:
izecul (01-10-2011)
Old 01-10-2011, 05:55 AM   PM User | #6
izecul
New Coder

 
Join Date: Jan 2011
Posts: 10
Thanks: 4
Thanked 0 Times in 0 Posts
izecul is an unknown quantity at this point
Both ideas sound good.
I also thought of a third one, whereby I pass a table-specific keyword into my AJAX handler, which then looks up the mapping and queries the corresponding table. But if I use the database, I double the queries per request - and if I use a file, I'll have to check it before proceeding everytime. And if I perform the lookup only once, storing it on a variable client-side, then it's no longer safe again...
Any thoughts?
izecul is offline   Reply With Quote
Old 01-10-2011, 08:07 AM   PM User | #7
adarshakb
Regular Coder

 
adarshakb's Avatar
 
Join Date: Jun 2009
Location: Silicon valley of india
Posts: 247
Thanks: 11
Thanked 1 Time in 1 Post
adarshakb has a little shameless behaviour in the past
Quote:
Both ideas sound good.
I also thought of a third one, whereby I pass a table-specific keyword into my AJAX handler, which then looks up the mapping and queries the corresponding table. But if I use the database, I double the queries per request - and if I use a file, I'll have to check it before proceeding everytime. And if I perform the lookup only once, storing it on a variable client-side, then it's no longer safe again...
Any thoughts?
..how about you do the querying only once and store it in a session variable.
..Or a better solution would be to handcode the array but it wouldnt be dynamic.
__________________
Two things are infinite: the universe and human stupidity; and I'm not sure about the universe.

Albert Einstein
-----------------------------------------------------
My Blog songs
adarshakb is offline   Reply With Quote
Old 01-10-2011, 12:25 PM   PM User | #8
izecul
New Coder

 
Join Date: Jan 2011
Posts: 10
Thanks: 4
Thanked 0 Times in 0 Posts
izecul is an unknown quantity at this point
Quote:
Originally Posted by adarshakb View Post
..how about you do the querying only once and store it in a session variable.
This sounds feasible, but what would be the impact on the server as traffic goes up?

Quote:
..Or a better solution would be to handcode the array but it wouldnt be dynamic.
Hand-/hard-coding the array will make the whole thing less flexible. As it is, I am looking for a script I can use on all pages, where the only changes I have to make when I add AJAX lookups is on the arguments for the 'input' tags.
izecul is offline   Reply With Quote
Reply

Bookmarks

Tags
ajax, database, multiple requests, security, table

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 05:16 PM.


Advertisement
Log in to turn off these ads.