Wednesday, March 30, 2011

Creating A Database using Hostmonster

Now that you understand the basics of relational database design, we can log onto the web server and actually create a database. Throughout the rest of this book, in the chapters that discuss MySQL and PHP, we’ll continue building and enhancing HMS, our Hotel Management System, as our example database application. If you have a different project in mind, feel free to adapt the examples as you go. However, you will probably find it easier to start by following the examples as they appear. Once you’re happy that the HMS system is
working properly on your server, you can then adapt it into whatever you want.
To create a MySQL database, you’ll need to find out how this is done on the particular hosting platform that you’re using. Here’s how to do it with site5 and hostmonster.

Creating a Database with Hostmonster

In the case of Hostmonster, creating a database is done through the Databases section of the control panel. So we start by logging into the control panel at hostmonster.com, with our username of thewebbo and the relevant password. This brings up the control panel, the relevant part of which is:

To create a database, click on the MySQL Databases link. You’ll see the following screen:


As you can see, I currently have two databases created (thewebbo_cms and thewebbo_rs44). Hostmonster adds a prefix to its databases, based on the username of the hosting account they belong to, hence thewebbo_ at the start of each database name.
We need to create a new database for our hotel management system. We’ll call it hms for simplicity. So, in the Create New Database section, type hms and click Create Database.
You’ll see a confirmation message:


And that’s all there is to it. But note that the database name is thewebbo_hms rather than plain hms, for reasons stated earlier. You’ll need to know the name of your database later, when we start to write PHP programs that access it.
With the database created, we have no further need for this part of the control panel. So click the Home link at the bottom of the screen to return to the main control panel screen and the full menu of database-related things.
The third option says "phpMyAdmin". This is a web-based program for managing MySQL databases on a remote server. It’s a free, open source application that just about every web hosting company offers for use by customers (ie you, rather than the people who visit your web site). It lets you create tables within databases, and it lets you create and manage the columns and rows within those tables. The only thing that it can’t do (at least, not in a way that satisfies the security requirements of most hosting companies) is to create the databases themselves, hence the previous step.

From now on we’ll use phpMyAdmin to manage our new thewebbo_hms database and to create the tables in it. Later on, we’ll write some PHP code which will use those tables to create a simple web-based hotel management application.
You’ll be using phpMyAdmin extensively while you develop web sites, so it’s a good idea to grab its URL from the control panel and save it as a shortcut or favourite. You’ll still need to enter your control panel username and password each time you access it, but at least you’ll be able to go straight to the program without first logging in to the control panel. To do this, just surf to phpMyAdmin as normal and then add the address to your web browser’s favourites. Or copy the URL, and paste it into whatever web bookmark manager you prefer to use. Or you could even save it as a shortcut on your desktop, for easy instant access.


0 comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Grants For Single Moms