Help - Search - Members - Calendar
Full Version: Looking for suggestions to secure database
HTMLHelp Forums > Programming > Databases
CharlesEF
Hi All,

I'm going to setup a MySQL database on my hosting server. I will use HTML to build the inferface to the database, I guess like everyone else does. Since I don't want anyone to know the location or username/password of the database I'm 'assuming' that I should not use javascript to open the database connection. I think I should use PHP to open the connection. In the past I have opened the connection once and left it open until I was done (intranet). I see no reason to open/close the database every time I pull or put information into it.

Since I'm new to PHP I want to get some feedback from the pros. I'm thinking I should use PHP to handle all database operations which means each html page would post to itself or a script to do this.

Is my thinking wrong?


Thank you for any input,

Charles
jimlongo
Usually most books teach the php mysql interface since it's a little easier (more procedural instead of object based)

However since you're just starting you might think about beginning with the mysqli interface instead of mysql (since it's deprecated).
Either way there's lots of examples on php.net to help you along.

Normally you store the username, password, host as CONSTANTS in a settings file that you can include when you need it.
And it's good practice to open and close connections as you need them.
You'll probably find it easier to write all your pages.php instead of pages.html

There's lots of good books and tutorials on all of this.
Brian Chandler
I don't even really understand how you can (directly?) access a database on the server from javascript.

Yes, you write PHP programs to access the database and convert the results into an appropriately formatted html page. This doesn't necessarily involve pages posting to themselves (what would that even mean, except that the input form might be on the same page as the results).
CharlesEF
Thanks for your input. Time to do more research.


Charles
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2019 Invision Power Services, Inc.