Article

Build PHP Applications With Macromedia Dreamweaver MX

Page: 1 2 3 4 5 6 Next

Breaking Ground

Dreamweaver MX makes things easier by allowing you to organize the components of a Web application - static as well as dynamic - into a single entity called a "site". In order to begin, create a new site via the Site-> New Site menu and say hello to the wizard that appears.

First up, you need to specify your working directory for the site - the name of the site, the root folder for the files and the default folder to look in for images. These folders may be on your local machine, or on a different machine - Dreamweaver refers to this collection of data as the "local site".

1232_image5

You can also optionally tell Dreamweaver about a "remote site" - this is usually the location where your Web server is running, and where your files will ultimately go for testing and deployment. Dreamweaver allows you to also specify the access mechanism for such a remote site - FTP, LAN, SourceSafe and so on.

1232_image6

Finally, if you're developing dynamic pages, you should also specify a "testing server" - this is a folder which can be used by Dreamweaver to process your scripts and dynamically generate documents, either from a database or elsewhere. In an Apache+PHP+MySQL environment, this folder would be the same as the root folder for the application on the Web server. You can also specify a URL prefix, which is used when you try to access the application via a Web browser.

1232_image7

Here's a list of the values I specified when creating a sample site in
Dreamweaver:

Local info:  
Site name: melonfire  
Local root folder: C:\Apache\htdocs\melonfire\  
 
Remote info:  
Access: FTP  
FTP Host: cerberus  
Login: me  
Password: **  
 
Testing server:  
Server model: PHP MySQL  
Access: Local/Network  
Testing server folder: C:\Apache\htdocs\melonfire\  
URL prefix: http://localhost/melonfire/  

In case you missed something, all this means is that I'll be doing all my development on my local machine (which has Apache, PHP and MySQL all talking to each other) in the folder "C:\Apache\htdocs\melonfire\", and will also be uploading copies of the files to a remote server named "cerberus" via FTP

Naming Names

Once your site has been set up, it's time to get started with a simple example - a page that display PHP environment settings via the phpinfo() function.

Dreamweaver provides you with an easy way to get started with building a PHP script - pop open the File -> New menu, and select "Dynamic Page" and "PHP" from the pre-defined templates.

1232_image8

You can now add the function call to phpinfo() in this page - switch to the code view using the View -> Code menu option, and type the following code into your document:

<?php phpinfo(); ?>

Save the file, and have Dreamweaver preview it for you via the toolbar icon (you can also hit the F12 key) and a new browser window should pop up with the output of the script.

1232_image9

If you're using PHP, you're going to be doing a lot of form processing - let's see how you can speed up the process in Dreamweaver. First, create a simple, properly-formatted HTML form using a combination of the "Tables" and "Forms" tabs on the "Insert" panel - this form should contain two text input areas, one named "name" and the other named "comment".

1232_image10

Add a couple of submit and reset button and the form is ready for action.

1232_image11

Here's the code:

<html>  
<head>  
<title>Untitled Document</title>  
</head>  
 
<body>  
<form action="this.php" method="post">  
<table width="75%" border="0">  
 <tr>  
   <td>Name</td>  
   <td><input name="name" type="text"></td>  
 </tr>  
 <tr>  
   <td>Comment</td>  
   <td><textarea name="comment" cols="" rows=""></textarea></td>  
 </tr>  
 <tr>  
   <td><input name="submit" type="submit" value="Submit"></td>  
   <td><input name="Reset" type="reset" value="Reset"></td>  
 </tr>  
</table>  
</form>  
 
</body>  
</html>

If you liked this article, share the love:
Print-Friendly Version Suggest an Article

Sponsored Links