Do you need to create dynamic sites, for example generate menus or web charts based on database values or save a contact form in the database ? To run dynamic web applications you need a server (Apache) a server-side language (PHP) and a database (Mysql). These are provided by the hosting companies for the live application (you should check yours) but if you build dynamic webpages using Dreamweaver then you’re also going to need a local testing server so you could test the application on your machine before deployment on the live server.
A PHP&MySQL server installed on a PC is called shortly WAMP (Windows-Apache-MySQL-PHP). You can install them manually: if you need just Apache you can get it from http://www.apache.org/ . But if you need also the MySQL database, you should download it and install it manually and the same goes for PHP.
The good news is that there are some one step installation programs that include Apache, MySQL and PHP. You also get phpMyAdmin – an easy to use interface for the database management.
Now if you’re on a windows environment you can try XAMPP for Windows: http://www.apachefriends.org/en/xampp-windows.html
XAMPP has many features, it even tells you how secure are your web pages and your database. Normally, you don’t have a password for the database, so it’s advisable to set a password for that, and a password for the working folder (accomplished via a .htacces file) so your web pages won’t be visible in the network unless you provide the password.
After you set a password for the root admin user, for your web pages, and for the phpMyAdmin you can save them. Under the security tab in XAMPP you’ll see something like in the picture below:
Another solution for installing Apache, PHP and MySQL without any headaches is the WAMPSERVER 2.0:
The latest release of WampServer 2.0i [07/11/09] includes :
- Apache 2.2.11
- MySQL 5.1.36
- PHP 5.3.0
The difference can be seen quickly, it’s much simplified than XAMPP but you don’t have Perl, FileZilla installed or the possibility to add the Tomcat add-on.
Wampserver it’s build for the beginner user to get use to dynamic web pages.
Also you don’t have the security verification, because wamp doesn’t check for security issues so your web pages and your databases and exposed to users from your network.
If you are on a Mac environment you can try the MAMP: http://www.mamp.info/en/index.html.
The MAMP includes Apache, Mysql and PHP. MAMP installs a local server environment in a matter of seconds on your Mac OS X computer.
OK, if you did install one of the above solutions you have the testing environment set up. Now you need to setup Dreamweaver to work with dynamic sites.
You need to have folder on your computer where the site files will be and in this folder you should create a new folder for each site. Let’s define a site in Dreamweaver.
Open Dreamweaver, go to Site, select “New Site…”, select Advanced, under Local Info, enter the name for your website. In Dreamweaver, under the local root folder enter the name of the site folder or simply browse for the folder you have created for the site.
Go to the “testing server” tab, select server model : PHP MySQL, then from the Access drop down: Local/Network. The Testing server folder is the place where you’re files are going to be stored on the testing folder, so it’s best that you go to the default www folder inside the XAMPP or WAMSERVER installed. In XAMPP you can find the www folder in C:\Xampp\htdocs\. For WAMPSERVER go to c:\wamp\www . In the default www folder create a new folder and for the usability sake, give it the same name as the site.
In the URL prefix the location should be http://localhost/your_folder. If you misspelled the name of the site, Dreamweaver will show a popup window telling you that the name of the site doesn’t match with the URL prefix, like in the picture below.
I will assume you have created a database via PhpMyAdmin – you can access PhpMyAdmin via XAMPP or WAMPSERVER interface.
Select from Dreamweaver “window” and then “databases” or press CTRL+SHIFT+F10 in order to display the databases tab. Press the + icon and select the MySQL Connection. A popup window will appear where you have to set the following items: connection name (put the site name there), MySQL server (default should be localhost), user name for the MySQL login, (usually the root user) and the password for the user. Dreamweaver tests the connection, and if everything is alright it should show you a popup window to select your database, like in the picture below. After that, press ok and you’re done.
In the upper Dreamweaver menu go to File, select New file, select PHP, in the Layout: select <none>. Save the file “index.php” in your local folder “D:\local_folder\demo_site”.
Select view code, set the HTML title “First PHP Test Page” (between the <title> tags and in the body (between the <BODY> tags), enter the following code :
Let’s explain the code. In order to use PHP we have to place it in PHP tags, <?php (your code goes here) ?>, or <? (your code goes here) ?> . The echo tag simply displays what you write inside the qoutes, in our case a simple Hello World text. In the end you have to put “;” in order to display the text, else it will give you an error. (Parse error: syntax error, unexpected T_ECHO, expecting ‘,’ or ‘;’ ). See the picture below.
Now press F12 and in your browser you should see in the adress bar “http://localhost/demo_site/index.php” and the text should be like in the picture below.
You are all set now to create dynamic applications in Dreamweaver and test them locally. You should learn how to create SQL queries to retrieve information from the database, and how to output the result using PHP. If you want a quick jumpstart you can use Dreamweaver extensions that generate PHP&MySQL code; for example here is a tutorial on how to create a simple menu using Creative DW Menus and a tutorial about creating a simple web chart with FusionCharts for Dreamweaver.