How to use PHP to access MySQL?
Posted by: fotsvl
Posted on: 2009-06-11 23:14:00
Forgive me if this seems like a very simple question, but I am having a lot of trouble figuring out how to access a MySQL database I've created on DreamHost.
As the membership coordinator for a local nonprofit, I'm making a page for our web site that will allow people to sign up online. I've created a form to input the data, and tested it using DreamHost's form-to-email application (it works fine). But what I really want to do is put that data in a MySQL database.
This seems simple enough, and there's tons of info on using PHP to do this. But nobody seems to say where the PHP script goes on my web server, or how it can access the MySQL database -- which requires a login and password. I obviously don't want people to be able to see this info if it's embedded in the PHP script (which, it seems to me, it must be). How is this done? Do I create some sort of password-accessible subdirectory? If so, how do I hide the password that allows access to that? I don't get it.
Sorry if this is obvious to everyone else. I'm really new at this! Thanks in advance for any help.
-Craig