The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Looking for suggestions to secure database
CharlesEF
post Oct 29 2013, 10:36 PM
Post #1


Programming Fanatic
********

Group: Members
Posts: 1,563
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jimlongo
post Oct 29 2013, 11:41 PM
Post #2


This is My Life
*******

Group: Members
Posts: 1,125
Joined: 24-August 06
From: t-dot
Member No.: 16



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.


This post has been edited by jimlongo: Oct 29 2013, 11:45 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Oct 29 2013, 11:52 PM
Post #3


Jocular coder
********

Group: Members
Posts: 2,298
Joined: 31-August 06
Member No.: 43



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).
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Oct 30 2013, 09:26 AM
Post #4


Programming Fanatic
********

Group: Members
Posts: 1,563
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



Thanks for your input. Time to do more research.


Charles
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 17th January 2019 - 08:36 PM