(eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

download (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

of 36

Transcript of (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    1/36

    http://www.interakt.ro

    Dreamweaver MX with PHAkt and PostgreSQL

    Alexandru COSTINInterAKT Online

    Dreamweaver MX - PHP - PostgreSQL 1

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    2/36

    http://www.interakt.ro

    Table of ContentsOverview................................................................................................3

    Setting up the workplace................................................................................3

    Prerequisites........................................................................................3

    Our configuration....................................................................................3

    Installing PHAkt.....................................................................................3

    The PostgreSQL database..............................................................................4

    Development stage.......................................................................................5

    Configuring the site in Dreamweaver MX..............................................................5

    Local Info......................................................................................5

    Remote Info.....................................................................................6

    Testing Server..................................................................................7

    The Testing Server section refers to the type of connection and protocol used to connect to a

    test server. An http address and a physical address are also required.........................7

    Cloaking and Design Notes.......................................................................7

    Site Map Layout and File View Columns..........................................................7

    Site folder structure.............................................................................8

    Connecting to the database...........................................................................8

    Using PHAkt............................................................................................11

    Managing users......................................................................................11

    Implementing the contact management...................................................................22User authentication..............................................................................22

    Conclusion.............................................................................................33

    Appendix 1 : References................................................................................34

    Appendix 2:: Configuring PosgreSQL on Windows.........................................................34

    Installing PostgreSQL...............................................................................34

    Appendix 3:: PHAkt improvements over the PHP_MySQL server model......................................35

    Appendix 4:: Tutorial files...........................................................................36

    Dreamweaver MX - PHP - PostgreSQL 2

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    3/36

    http://www.interakt.ro

    Overview

    InterAKT is a software development company specialized in designing software tools for web development.One of their most successful tool is PHAkt, a GPL Server Model for Dreamweaver MX, allowing visual PHPdevelopment. PHAkt is the only alternative server model for Dreamweaver MX and makes some

    improvements over the original PHP_MySQL server model that ships with Dreamweaver MX.

    In this tutorial, we will create a password protected dynamic site that will permit contact management for aclient's employees. This tutorial will demonstrate how Dreamweaver MX can be used to create databasedriven websites, using PostgreSQL as database and PHP as the scripting language.

    We recommend PostgreSQL as a professional database for all websites. We have choosen it because of itslarge, professional feature set. There are other GPL databases on the market that you can use and theportions of this tutorial that deal with PHAkt and Dreamweaver MX will remain unchanged.

    Setting up the workplace

    Prerequisites

    To complete this tutorial, you will need Dreamweaver MX installed on a Windows or MAC platform; thePHAkt 2.x extension; direct, FTP or share access to an Apache (you can also use other webservers like IIS,PWS or OmniHTTPd)/PHP webserver (we recommend PHP 4.0.6 and above), access to a PostgreSQLserver and phpPgAdmin, a web tool used to manage PostgreSQL databases, installed and configured onthe web server (phpPgAdmin is). For a complete list of references to all those products, please consult thereferences section in Appendix 1.

    All the screenshots in this tutorial are made with Dreamweaver MX running on a Windows XP Home Edition.

    During this tutorial will use some formatting conventions for some text elements having significant

    importance for the application presented: file name italic, folder name bold, recordset name bold, fieldnamebold italic.

    Our configuration

    We have created this tutorial on a computer configured as follows:

    Web server: Apache 1.3.24 with Server Root in c:/www/ located on the same computer as DreamweaverMX

    PHP 4.2.1 located in C:\php4\ and configured as a CGI module to Apache. PostgreSQL 7.2.1 compiled with Cygwin, which is located in C:\Cygwin\. In the Cygwin bash,PostgreSQL is installed in /usr/local/pgsql/ and the databases are stored in /usr/local/pgsql/data/

    In this tutorial, we'll refer to the PostgreSQL server address as pgserver, and the web server address aswebserver. In our specific case, they will both be on the localhost.

    Installing PHAkt

    PHAkt can be downloaded from the Macromedia Exchange, athttp://dynamic.macromedia.com/bin/MM/exchange/extension_detail.jsp?extOid=338683.

    Unzip the downloaded file into a new folder and you will find the whole software package, including theREADME files and the MXP files to install into Dreamweaver MX. Read the README for the latestinformation that may effect your install, then open Dreamweaver MX and select Command ManageCommands to open the Extension Manager then install the phakt-2.0.60.mxp extension.

    Please remember that in the Windows 'NT' series (this includes NT, 2000 and XP), the extensions areinstalled for each user individually, so if one of your colleagues has some extensions installed in his copy of

    Dreamweaver MX - PHP - PostgreSQL 3

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    4/36

    http://www.interakt.ro

    Dreamweaver MX in his workspace, you will not see them. You need to install a copy into each user' sworkspace if you have multiple users on the same computer.

    The PostgreSQL database

    We' ll assume that you have the PostgreSQL server up and running on the localhost. (for more detailed

    instructions on how you can install and start PostgreSQL on a Windows (NT/2000/XP) server, please readAppendix 2).

    You will have to use the phpPgAdmin web interface to create a database named phakt_mx and thenexecute the SQL script (phakt_mx.sql) located in this tutorial attached files.

    Dreamweaver MX - PHP - PostgreSQL 4

    Figure 1 Creating the phakt_mx database

    Figure 2 Executing the phakt_mx.sql file

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    5/36

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    6/36

    http://www.interakt.ro

    Remote Info

    In the Remote info section of the dialog you will have to indicate the connection type used to upload the fileson the production server and the actual path to the remote computer. You can also select to automaticallyupload files on the server on save, which can be very useful and will save you a lot of ' Ctrl+Shift+U' keypresses. If you are working in a team, you might also choose to activate the Check In/Check Out supportthat will help multiple users not to edit the same file at the same time.

    Dreamweaver MX - PHP - PostgreSQL 6

    Figure 5 Setting up the Remote Info Section

    Figure 4 Setting Up the Local Paths

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    7/36

    http://www.interakt.ro

    Testing Server

    The Testing Server section refers to the type of connection and protocol used to connect to a test server. Anhttp address and a physical address are also required.

    Please note that correctly configuring the testing sever is very important for your site to function. Because allthe database information is loaded by uploading and executing PHP scripts on the testing server, you haveto carefully configure this screen.Please also note that you have to set the sever model for your site to PHP_ADODB (PHAkt 2 MX servermodel). If you select the built-in PHP server model you will only be able to connect to mySQL databases andyou will have significantly fewer features than you will with the PHAkt server model.

    Cloaking and Design Notes

    Site cloaking enables you to exclude folders and file types in a site from operations such as Get or Put. Youcan cloak individual folders of file types, but not individual files.

    Design Notes are notes that you create for a file. The Design Notes are associated with the file theydescribe, but stored in a separate file. You can use Design Notes to keep track of extra file informationassociated with your documents, such as image source-filenames and comments on file status.

    Site Map Layout and File View Columns

    The purpose of Site Map Layout dialog box is to customize the appearance of your sitemap. You canspecify the home page, the number of columns to display, decide whether the icon labels display thefilename or the page title, and whether to show hidden and dependent files.This configuration section has the role to make changes to the file view columns in the Site panel. You canchange the order of columns, add a new column, or delete a column.

    Site folder structure

    This tutorial relies on a simple file structure with a root folder called pgsql where all the files will be stored.We will create two sections in the website, one for the site administrator, and one for the site users. The site

    Dreamweaver MX - PHP - PostgreSQL 7

    Figure 6 Setting up the Testing Server

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    8/36

    http://www.interakt.ro

    administrator will be able to manage users, and the users will be able to manage their contacts. We willcreate the admin folder in the root folder, and we' ll store here the files used to manage the users. We willalso create here the contacts folder, where we' ll put the files for contact management.

    When you create the connection in Dreamweaver MX, PHAkt will create and upload the Connections foldercontaining a file describing the connection parameters and the adodb folder which contains all ADOdb

    components. PHAkt will also create an includes folder containing functions.inc.php, the file that containsmost common used functions.

    Create an new file index.phpin your site' s root using the Dreamweaver MX. This can be done by selectingthe folder in which you want to create a new file or a child folder and then use the mouse right button. Openthe index.phpfile by double clicking on it in the Files panel.

    Connecting to the database

    First of all, we should check that the correct Document Type is selected for the current document. To do thatgo in the Edit Menu and choose Preferences. In the configuration window that will appear you have to chosePHP4, in the New Document tag, as the default document type.

    To make sure that PHP4 is selected as the document type, check the file contents, it should have acomment stating ' PHP ADODB document - made with PHAkt 2.0.60' . In case this comment is not presentwithin your page code, you should change your document type as seen in the prevoius image.

    Dreamweaver MX - PHP - PostgreSQL 8

    Figure 7 Creating a New File

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    9/36

    http://www.interakt.ro

    To create a connection go to the Databases tag from the Application panel, push the '+' button and select' ADODB connection' .

    Dreamweaver MX - PHP - PostgreSQL 9

    Illustration 8 Setting the New Document Type

    Illustration 9 Made with PHAkt Comment

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    10/36

    http://www.interakt.ro

    The connection configuration window will appear like in the picture below (actually this picture shown thecompleted connection)

    You will have to fill out some fields describing the connection to be created. In the Connection Namefieldwill contain the name of the connection used for this application: test, the Database Typewill specify thetype of the database server which in our case is PostgreSQL 7.x, the database server requires the computername or IP address of the machine running the database server described above, in our case is localhost.You will also have to specify an User Name, in our case Administrator and a password - phakt.

    After you set up all those parameters, you can click on the Select button, and a list of all possible databaseswill be shown.

    Dreamweaver MX - PHP - PostgreSQL 10

    Figure 10 Creating an ADODB Connection

    Figure 11 Configuring an ADODB connection

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    11/36

    http://www.interakt.ro

    Select the desired database, phakt_mx, which you created when you set up PostgreSQL earlier in thetutorial, and then press OK. The database Locales Fields will decide the date format (Ex. m-d-Y or d-m-Y),the messages locales and the type of database connection which can be 'connection' (a standardconnection that expires once you leave the page) or 'permanent connection' (it uses the PHP pconnect()function to create a persistent connection). Having permanent connections could dramatically increase yourperformance, as connecting to some databases (especially postgreSQL), is very cost consuming so it' s verywise to use a connection pool to serve your dynamic pages.

    Click OK and you will have a new connection stored in the test.phpfile created in the Connections folder.

    Using PHAkt

    The following pages will show you how to use many of the improved functionalities in PHAkt to create acomplex dynamic website. Don' t forget, to be able to see the page running on the server, you have toupload it there by using Ctrl+Shift+U.

    Managing usersTo manage the users, we' ll create 4 separate pages with PHAkt2, with the purposes of listing the users,adding new users, editing a user' s profile and deleting a user. These files will be stored in a separate foldernamed admin placed in your site root folder (pgsql). Then create the admin/index.phpfile that will containthe list of users. To do that select the folder in which you want to create the file and use the mouse rightbutton.Open this file and create a rsUsers recordset by clicking on '+' in the Bindings tab of the Applicationpanel.

    Dreamweaver MX - PHP - PostgreSQL 11

    Figure 12 Selecting a database

    Figure 13 Creating a Recordset

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    12/36

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    13/36

    http://www.interakt.ro

    Click OK and you' ll notice that the repeat region was added to the page. You have to also add a navigationbar that will allow you to navigate between the recordset pages if there are more then 10 records in thetable. This can be done easily by positioning the cursor in the outer right section of the table, then selectingthe Application tab in the Insert panel , then clicking on the Recordset Navigation Bar button.

    Select the ' Text'radio button, then press OK.

    Your page should look like this:

    Dreamweaver MX - PHP - PostgreSQL 13

    Figure 16 Configuring a Repeated Region

    Figure 18 Configuring a Navigation Bar

    Figure 17 Repeated Region Layout In Macromedia

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    14/36

    http://www.interakt.ro

    Save the file by clicking on Ctrl+S or selecting Save from the File menu.

    Now we need to handle the case when the users_usr table will be empty. At the top of the page above thetable where the data is supposed to be returned, write a warning message that the data set returned isempty. Select the text you just entered and add a Show If Recordset Is Empty Server Behavior on the page.

    The table page will look like this:

    Dreamweaver MX - PHP - PostgreSQL 14

    Figure 19 Users List Page Preview

    Figure 20 Creating a Show If Region

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    15/36

    http://www.interakt.ro

    We' ll continue by creating an Insert Record Server Behavior, that will allow us to add records in theusers_usr table. Create a new file and save it as insert.php in the admin folder. In the index page where youare working, add a new link in the lower right cell of the username list table to the insert.php file. This can bedone by writing ' Add' in the table, then selecting the text, right clicking on it, then selectMake Link and a filebrowser dialog will be shown. Select the insert.php file and click OK.

    Now edit the insert.php file, then click on the Record Insertion Form from the Insert panel, Application tab.

    Dreamweaver MX - PHP - PostgreSQL 15

    Figure 21Page Preview with the Show If Region

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    16/36

    http://www.interakt.ro

    Fill the form as show above. You should note that the id_usr field is ' Text' and this means that it will not beeditable when we' ll add a new record. Theindex.php file referred in the above window, is the PHP fileplaced in the admin folder. Click OK and a new form will be created.

    We' ll continue now by testing our configuration. To do this, we' ll select the site root in the File panel, Sitetab, then click on the Upload button. We are doing this because PHAkt generated PHP files require someother files to be uploaded on the server, and uploading only some of the files will generate errors.Click Yes when Dreamweaver MX asks you if you want to upload the entire site.

    Now start your browser and point it to http://localhost/pgsql/admin/. You should see a page like the onepictured below. As you can see, because the recordset is empty, the warning message will be shown.

    Dreamweaver MX - PHP - PostgreSQL 16

    Figure 22Creating a Record Insertion Form

    F

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    17/36

    http://www.interakt.ro

    Click on the Add link, then fill the username and password fields with admin/admin, the level field with 10and then press the Insert Record button.

    Next we' ll create theupdate.phpand delete.php files in the admin folder, , then edit them and add theUpdate Record and Delete Record server behaviors. We will have to pass a URL parameter to each of thepages we created when we link to them so we should establish now that the parameter will be called id_usr.

    Let' s see how the Update Record SB will be added to the page. Open theupdate.php file. Create arecordset named rsUser, select the users_usr table and set the filter for it as id_usr from the databaseequals the URL parameter id_usr. The recordset dialog should look like in the figure below.

    Then add a Record Update form to the page, and configure it as in the figure below. As you can see, we

    Dreamweaver MX - PHP - PostgreSQL 17

    F

    Figure 25 Creating the rsUser Recordset

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    18/36

    http://www.interakt.ro

    have chosen to redirect to admin/index.phpafter updating an user. Press Ctrl+Shift+U or use the Site Panelto upload the page to the server.

    Now we' ll have to modify theadmin/index.phppage, and to make the Edit text in the right column load therecord update page. Select the Edit text, then add the Go to Detail Page Server Behavior.

    Configure the link to pass the id_usrURL parameter to the update.phppage, then click OK.

    You have now a fully functional insert/update list, and we' ll continue with implementing the delete recordfeature, as shown below.

    Edit the delete.phppage and add a Delete Record behavior as shown in the figure below. The index.phpDreamweaver MX - PHP - PostgreSQL 18

    Figure 26 Creating a Record Update Form

    Figure 27Creating a Go To Detail Server Behavior

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    19/36

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    20/36

    http://www.interakt.ro

    Allow access only to the level 10 users and choose to redirect towards the admin/login.phpfile.

    Now open the login.phpfile and add a form containing two text fields and a submit button. The fields nameswill be username and respectively password, while the Max Chars property for each field will be set to 8.Don' t forget to define the password field as being a password type field.

    Dreamweaver MX - PHP - PostgreSQL 20

    Figure 30 Creating a Restrict Access to Page

    Figure 31 Configuring a Restrict Access to Page

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    21/36

    http://www.interakt.ro

    Now go to the Server Behavior tag in the Application panel and add a User Authentication/Log In Userserver behavior.

    Now open the admin/index.php file and create a link to the logout page. Save the file and upload the site.

    Play a little with your small but functional web application from a browser. It should perform well, as PHAktcode was tested by many users all over the world.

    Before passing to the next section of the tutorial, please create the user phakt with the password user, asthose will be used as default information below.

    Dreamweaver MX - PHP - PostgreSQL 21

    Figure 32Editing the Properties of aTextfield

    Figure 33 Creating a Log In User Server Behavior

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    22/36

    http://www.interakt.ro

    Implementing the contact management

    We' ll continue our tutorial by adding new features in the application that will allowauthenticated users toview and manage a contact list. First of all, we' ll create files calledindex.php, insert.php, update.phpanddelete.phpin the contacts folder.

    User authentication

    To implement the user authentication, we' ll create, in thecontacts folder, a login and logout page, namedlogin.phpand logout.php.

    In the login.phppage create a simple HTML form on the page, containing two text fields named usernameand password, and a submit button. To change the name of a text field, you have to click on it then modifyit' s name in the properties panel. Also set the Max Chars parameters to 8 for both the username and thepassword. Note: the password field should have the propetrty password turn on. (Alexandru why limit it to8? Best to tell a user why they are doing this.

    Then add the User Authentication/Log In User Server Behavior on the page, and configure the behavior asseen in the picture below:

    Dreamweaver MX - PHP - PostgreSQL 22

    Figure 34 User Login Page Layout in Macromedia

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    23/36

    http://www.interakt.ro

    In this behavior, we pass a supplemental URL parameter named failed when the login fails, to be able toshow a warning message. To do this, we' ll have to switch to code view, because PHAkt does not come witha Server Behavior that allows you to create conditional regions.

    Add a simple PHP 'if' code, that will check if the failed parameter is set like in the picture below.

    The login user code we have added in the login.phppage does the authentication, then stores the username(from the username_usrtable fields) in the KT_Username session variable. We will use this session variableto filter the records from the contacts table for the currently logged in user.

    Dreamweaver MX - PHP - PostgreSQL 23

    Figure 35 Login User Server Behavior - Contacts Section

    Figure 36 Inserting an Error Message

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    24/36

    http://www.interakt.ro

    Because all the rest of the pages will need the user id, and not the username (because the contacts_conpage is linked to the users_usr page with the id), we' ll manually add some code that will store the user id ina session variable. The best place to add this code is below the ' // Add code here if you want to dosomething if login succeeded' line in the login user server behavior, which is there especially to allow you toadd any code you may need like this.We will manually create a recordset and keep the user id in the ' userID' session variable.

    We will have to protect all the pages from the contacts folder (excepting login.phpand logout.php), byopening them then adding the User authentication/Restrict access to page Server Behavior. This operationis mandatory for the pages to function correctly, as the PHP session is started in this code block, and if it isnot present, the session variables will be unavailable.

    Open the logout.phpfile and insert the User authentication/Logout user server behavior.

    Now upload the whole contacts folder on the server.

    Dreamweaver MX - PHP - PostgreSQL 24

    Figure 37Adding a Recordset Manually

    Figure 38 Restrict Acces To Page - Contacts Section

    Figure 39 Logout User Server Behaviour

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    25/36

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    26/36

    http://www.interakt.ro

    PHAkt will create a table containing a repeated region containing the Master Page Fields that you havespecified in the configuration window. Also a navigation bar and a position menu will be created. Thedetail.php file will also be created and it will contain a table displaying all the Detail Page Fields that youhave specified in the Master Detail Configaration window.

    As you can see at this moment we don' thave any possibility to insert, edit or delete a record. TheseDreamweaver MX - PHP - PostgreSQL 26

    Figure 41 Creating a Master Detail Page Set

    Figure 42 User Contacts List Page Layout in Dreamweaver

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    27/36

    http://www.interakt.ro

    features have to be added separatly along with a logout link or button.

    First we' ll create table having one row and twocolumns. This table will contain the link to the insert.phpandlogout.phpfiles that will handle the insert and the logout features. In the first column, write ' Add new record' ,select the text and create a link to the insert.phpfile using the mouse right button. In this file we' ll add anInsert Record Form that will allow us to add contacts to this user contact list.

    As the image shows, we' ll configure theidusr_conto be a hidden field and it will be initialized with$HTTP_SESSION_VARS[' userId' ], that means that will contain the id of the currently logged inuser. PressOK, save the file and go back to the contacts/index.php.

    Write ' logout' in the right table column, select the text and create a link to thelogout.phpfile.

    To include the Edit and Delete features you will have to add two columns to the table containing the usercontacts. To add a column go in the last table field and use the mouse right button like is shown in the belowpicture:

    Dreamweaver MX - PHP - PostgreSQL 27

    Figure 43 Creating a Record Insertion Form - Contacts Section

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    28/36

    http://www.interakt.ro

    The configuration window that appears will require the number of columns and their position refered to thecurrent column:

    Select the last two fields from the first row and, using the mouse right button merge these two cells and thenwrite ' Actions' in the resulting cell. In the two cells placed below, write ' Edit' and,respectively, ' Delete'

    Add a Go To Detail Page Server Behavior by selecting the Delete text and point to the delete.php file like isshown in the following figure:

    Dreamweaver MX - PHP - PostgreSQL 28

    Figure 44 Table Insert Rows or Columns

    Figure 45 Insert Columns After the Current

    Column

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    29/36

    http://www.interakt.ro

    Now edit the delete.php file and add a Delete Record Server Behavior. Configure this sever behavior likefollows (the index.pxp referred in the one placed in the contacts folder):

    Save the file and upload it to the server.

    To create the edit feature select the Edit text from the table and create a Go To Detail Page Server Behaviorpointing to the update.php file and passing as URL parameter the id_convariable:

    Edit the update.php file and create a rsContact recordset that will use a filter after the id_usrvariable that is

    Dreamweaver MX - PHP - PostgreSQL 29

    Figure 46Go To Detail Page Server Behavior

    Figure 47 Creating the Contacts Delete Record

    Figure 48 Go To Detail Page - Contacts Update

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    30/36

    http://www.interakt.ro

    passed as an URL parameter:

    Then add, from the Application tab in the Insert Panel a Record Update Form:

    Save the file and upload the contact folder on the server.

    You should have a ready to use web application.

    Dreamweaver MX - PHP - PostgreSQL 30

    Figure 49 Creating the rsContact Recordset

    Figure 50 Creating the Contacts Record Update Form

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    31/36

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    32/36

    http://www.interakt.ro

    Dreamweaver MX - PHP - PostgreSQL 32

    Figure 53 Contacts Insert Page

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    33/36

    http://www.interakt.ro

    Conclusion

    Even if the designed application have some flaws, as we didn' t protected the admin section, we didn' t setmaximum values for the text fields, we don' t checktext fields for required values, we don' t ask forconfirmation on delete, we didn' t name our HTML pages (they are all called Untitled), we don' t check the

    values in the submitted forms, etc.

    Dreamweaver MX with the free PHAkt2 extension can be used to create powerful PHP applications. (2-4paragraphs, further readings, references)

    Dreamweaver MX - PHP - PostgreSQL 33

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    34/36

    http://www.interakt.ro

    Appendix 1 : References

    Macromedia Dreamweaver MX websiteInterAKT PHAkt websiteApache website

    PHP websitePostgreSQL websitephpPgAdmin websiteCygnus website

    Appendix 2:: Configuring PosgreSQL on Windows.

    Installing PostgreSQL

    If you don' t have a preconfigured PostgreSQL serverup and running, you will have to install the databaseserver on your own. We won' t enter in all the details here, because the installation docs on PostgreSQL' ssite are exhaustive, but we' ll present a quick way of installing PostgreSQL on a Windows NT (2000, XP)

    computer. PostgreSQL works on Windows because the Cygnus group has emulated all Linux APIs onwindows, making a lot of Unix products portable on the Windows platform.You have two choices for installing PostgreSQL. Either download the prepackaged version from theInterAKT website (read 1.Preconfigured installation ) or download Cygwin from the cygwin site, becausesome people have reported problems installing from the prepackaged version ( skip to 2.Installing fromscratch)

    1. Preconfigured installationYou will have to download the cyg-pgsql-1.0.zip file from our ftp server atftp://iakt.rdsnet.ro/pub/phakt/tutorial/, then extract it in the c:\folder. The Cygwin folder will be created andinside the PostgreSQL server is located.

    Enter the Cygwin folder and double-click on the cygwin.bat file. A bash session will be started and a console

    window will come up on screen. Bash, by the way, is a kind of command.com for Linux and other Unixesthat is simulated as a DOS edit window in Windows.

    2. Installing from scratchGo to the Cygwin website ( www.cygwin.com ) and click on the 'Install now!' link. Save the setup.exe filesomewhere on your harddrive.Launch it, choose Next->Install from internet->Next->NextYou will see a list of packages. Also select packages ' postgresql' and ' bzip2' . The rest of necessarypackages are already selectedAfter installation you must also download cygipc from this mirror:http://www.neuro.gatech.edu/users/cwilson/cygutils/cygipc/index.html, and place the file in the / directoryof the cygwin installation (usually c:\cygwin)

    execute the following commands in order to unzip the file to the ' /usr/local' directory> cd /> bunzip -c /foo.tar.bz2 | tar xvf -

    Execute the following commands, exactly as follows (all commands are lowercase):

    ipc-daemon&This will start the ipc process on your computer. IPC is responsible for providing shared memory support asthe SHM system in Linux, because Windows does not include this feature, but PostgreSQL needs it.

    initdbThis will create the database named template1 in the /usr/local/pgsql/data/ folder. You will be also informedthat the default user that has the right to connect to the database (in our case the user is ' Administrator' ).

    Note : If you try to initialize the database without having the ipc-daemon server running, the postmasterprocess will block and no error messages will be shown!Note : It is recommended to use the -W option for initdb (prompts the user or a password, usually the defultDreamweaver MX - PHP - PostgreSQL 34

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    35/36

  • 8/8/2019 (eBook) Building a Dynamic Website Using Dream Weaver Mx and Phakt

    36/36

    http://www.interakt.ro

    Appendix 4:: Tutorial files

    1.SQL to create the database2.completed site zipped

    3.site after the user management section is created continue tutorial4.site after the login is implemented, and the contact list continue tutorial

    5.php.ini6.httpd.conf7.pg_hba.conf8.confing_inc.php for phpPgAdmin