close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Web development tutorial

How to create a download center

Tutorial created by Team WebAssist

Categories: Data Bridge, eCart, Dreamweaver, PHP

rating

If you are selling digital goods, a download center is one of the most common ways to deliver your products to your customers. The Download Center will serve as a repository for downloading any digital product that a customer has purchased. Making it easy to access, and secure.

NOTE: Due to the advanced features included in PowerStore, these steps cannot be applied to a PowerStore site.

arrow downBefore you begin

Before you can add a Download Center to your online store, you will need to ensure that your customers register or log into your site before purchasing. You may also want to create the Order History pages to allow your customers to view the details of their orders. For more information, see the following tutorials.

  1. Applying Login/Registration to your checkout page
  2. Creating an Order History page

arrow downRequirements

You will need the following items before beginning:

  1. Dreamweaver CS3 or later
  2. Dreamweaver site with eCart checkout functionality with registration already created.
  3. DataAssist
  4. SecurityAssist
  5. Digital File Pro / File Manipulation features of CSS Form Builder 2
  6. Yahoo Search for BOSS (Optional)
  7. WebAssist Free eCommerce MySQL database (Optional) wa_ecommerce_db.zip
This tutorial refers to the Free eCommerce MySQL database that is provided by WebAssist. This database contains all the necessary tables and columns to complete this tutorial. If you are not using this database, you will need to review the table and column references to make sure they match up with your database structure.

arrow downSetting up your downloads

Before proceeding with creating your download center, you should set up your system (your server) for storing your downloadable files. Review the following information and make any changes to where you store your files if necessary before continuing.

The Database

The Free eCommerce MySQL database contains a ProductLocation column within the products table. This column is intended to be used for digital goods, if you need to store the filename or path for that product. For all the products in your products table that are digital goods, you should enter the filename to the file that the customer will be downloading.

You do not want to enter the path as this will be managed by Digital File Pro when we add the Download File Server Behavior.

If you are not using the Free eCommerce database, make sure to add a ProductLocation column, with a VARCHAR (250) Datatype, to your products table.

Where to store the downloadable files

The digital files that your customers will be downloading are probably very important to you, so you will want to protect them from unauthorized downloading. For this reason, you do NOT want to store your downloadable goods within your site root. This might enable someone to download them via a link without purchasing.

Instead, create a new folder on your server that is outside of the folder containing your site. Within this folder you should store all the digital goods. This way, they can only be retrieved using the Digital File Pro Download File Server Behavior applied to a page in your site.

Once you have set these two things up, continue with this tutorial to create your website's Download Center.

arrow downCreate the Download Center

The first step is to create your Download Center page using DataAssist.

  1. With a page from your current site already open, choose Insert > WebAssist > DataAssist > DataAssist Wizard.
  2. Choose your orderdetails table from the Table menu.

    In this example, my database connection is localhost - yours may be different, and that is fine.
  3. Click the Manage Pages tab.
  4. Click the Define Features button
  5. Add only a results page.
    Do not add any other pages as these pages will not be used.
  6. On the the customize Results page UI, click the Customize Your Results Page
  7. Select any column.
  8. Click OK on the Add Selected To List dialog.
  9. Click OK to close the Custmoize Your Results Page dialog.
  10. Rename that page download_center.php.
  11. Click Finish to create the page.
  12. Click OK on the Save As dialog ( you may save if you wish )

arrow downModify the Recordset

Now that DataAssist has created our download center page, we will modify the Recordset on the page to include the orders and products tables, as well as specify a parameter that checks to see if the product is a digital good.

  1. Open the Server Behaviors panel by choosing Window > Server Behaviors.
  2. Double-click to open the WADAorderdetails Recordset.
  3. If you do not see the SQL text area, click Advanced.
  4. Replace the Recordset that appears in the SQL text area with the following query.
    SELECT orders.*, orderdetails.*, products.*
    FROM orders INNER JOIN orderdetails on orders.OrderID = orderdetails.DetailOrderID INNER JOIN products on orderdetails.DetailProductID = products.ProductID
    WHERE orders.OrderUserID = paramUserID AND products.ProductLocation IS NOT NULL
    GROUP BY products.ProductLocation

    You should copy (Ctrl/Cmd C) the query from this page and paste (Ctrl/Cmd V) it into your SQL text area.
  5. Click Add ( ) to create a new parameter.
  6. In the Name field, enter paramUserID.
  7. Leave Integer specified in the Data Type field, and = in the adjacent field.
  8. In the Default Value field, enter -1.
  9. In the Run Time Value field, enter $_SESSION['UserID'].
    This references the UserID Session Variable that SecurityAssist created.
  10. Click OK to create the parameter.

  11. Click OK again to update the Recordset.

  12. Press Ctrl (Cmd) S to save the page.

arrow downApply SecurityAssist

Next, you will need to apply the SecurityAssist Access Pages Manager to this page to restrict access to logged in users.

  1. So that we can apply the Access Pages Manager to this page, switch to another open page, or open a different page from the Files panel.
    The Access Pages Manager cannot apply changes to a page that is the current page in Dreamweaver.
  2. From the WebAssist menu, choose SecurityAssist > Manage Site Access > Access Pages Manager...
  3. When the Access Pages Manager loads, select the download_center.php page.
  4. From the Grant access if field, choose Logged in to users.
  5. Click the If access denied, go to browse option, and select your users_LogIn.php page.

    This is the log in page for your site, it may be named differently.
  6. Click OK to apply this change.

arrow downCreate the Download button

The most important part of your Download Center is the download button. This is the button that, when clicked, will initiate the download of the file.

  1. Open your download_center.php page.
  2. Click once on the border of the table that displays the results.
    This will select the table. You will know you selected it when the entire table is wrapped in a bounding box.
  3. In the Properties Inspector, locate the number of Rows and Columns for the table.
  4. Increase the number of columns by 1 to add an additional column to the end this table.

    In this example, we will increase the number of columns (8) by 1, by changing the value 8 to 9.
  5. Place your cursor within the last cell of the table.
    This is where we will add the Download button.
  6. From the Insert menu, choose Form > Form.
    When a new form is inserted to your page, is is visible by a dotted red line.
  7. Next, from the Insert menu, choose Form > Hidden Field.
    We will use this hidden field to dynamically determine the path to the file to be downloaded.
  8. Place your cursor within the form (red dotted line).
  9. From the Insert menu, choose Form > Button.
  10. In the ID field for the button, enter download.
  11. Click OK to create the button.
  12. Click once to select your Submit button.
  13. In the Properties Inspector, change the value from Submit to Download.
  14. Click the Split button to switch to Code and Design view.
    This will allow us to make a quick change to the code.
  15. Place your cursor at the end of the form id (as shown in the figure below).

  16. Insert an underscore (_) at the end of this ID.
  17. Then, open the Bindings panel from Window > Bindings.
  18. Expand the WADAorderdetails Recordset.
  19. Select the ProductID option, and choose Insert.

  20. Repeat this process with name for the form.
    Depending on your Dreamweaver settings, you form may not have been created with a name field. If this is the case, ignore this step as the name is not required.
  21. Once you have made these additions, your code should match the following figure.

    You need to add these so that each form id and name is unique as it is repeated for each result on the page. This is not necessary for the hidden form element, or the button.
  22. Select the Design button to return to Design view.
  23. Select the icon representing the Hidden form element.
  24. From the Properties Inspector, choose the value lightning bolt.
  25. Expand the WADAorderdetails Recordset, and choose the ProductLocation column.
  26. Click OK.
  27. Press Ctrl (Cmd) S to save the page.

arrow downApply Digital File Pro

Next, we will apply Digital File Pro to the Download Center page to enable the secure download functionality.

  1. From the Insert menu, choose WebAssist > Digital File Pro > Download.
  2. From the Trigger menu, choose current page submit.
  3. From the folder menu, choose the Browse for file option and navigate to the directory that contains the files to be downloaded.
    IMPORTANT: For security reasons, you do NOT want to store your downloadable goods within your site root. This might enable someone to download them via a link without purchasing. Instead, create a new folder on your server that is outside of the folder containing your site.

  4. Click OK.
  5. Choose the File name lightning bolt.
  6. Expand the form option and select the Hidden form element.
  7. Click OK.
  8. Leave the default File name option specified.

  9. Click OK to apply the Download behavior.
  10. Press Ctrl (Cmd) S to save the page.


Your Download Center should now be functioning properly. You can test this by going to your site, logging in as a user that has made a purchase, and visiting the download_center.php page.

The next step is optional and will show you how you can create a link to display on a page in your site, that will display only if the current user has purchased a product that can be downloaded. This is often useful if you are selling a mix of digital and physical goods, and don't want to display download link for someone who has only purchased a physical good.

arrow downCreate a link to the page

This last step will add a link to the Download Center on one of your pages. As you can see at WebAssist.com we provide a link to the Download Center on the User Profile page. This is convenient because it is the first page a user sees after they have logged in.

Step 1: Create link

  1. Open the User Profile or User Update page for your site.
    The SecurityAssist Quick Insert Interface will create a User Profile page for updating a user's information. To create a User Profile page that is not updateable, you might want to run the DataAssist wizard on the users table, and apply SecurityAssist to restrict access to the logged in user.
  2. Place your cursor where you want your download link to display, and type the text for the link.
    You could also insert an image similar to the one on the WebAssist website.
  3. Highlight the text (or images) you wish to be the link.
  4. In the Properties Inspector choose the Link browse option, and select the download_center.php page.


Your link will now work and display on the User Profile page every time a user logs in. The following step is optional, but will show you how you can create a custom Recordset that you can use to only show this link when the user has purchased a digital good. This is useful for online stores that sell both physical and digital goods, and don't want to show this link to customers who have only purchased a physical good.

The following step utilizes Search for BOSS!'s Show If Utility. You will need this extension installed if you wish to proceed.

Step 2: Create the Recordset

This Recordset will check your orders, orderdetails and products tables to see if the currently logged in user has purchased a digital good.

  1. From the Server Behaviors panel, choose Add ( ) > Recordset.
  2. If not already in Advanced view, click the Advanced button.
  3. In the Recordset Name field, enter rsDownloadCount.
  4. In the SQL text area, paste the following SQL query.
    SELECT COUNT(products.ProductLocation) AS DownloadCount
    FROM orders INNER JOIN orderdetails on orders.OrderID = orderdetails.DetailOrderID INNER JOIN products on orderdetails.DetailProductID = products.ProductID
    WHERE orders.OrderUserID = paramUserID

    This query checks the logged in users order history to see if he has purchased a product that is downloadable.

  5. Select the Variables Add ( ) option.
  6. In the Parameters name field, enter paramUserID.
  7. Leave Integer selected for Type.
  8. In the Default value field, enter -1.
  9. In the Runtime value field enter $_SESSION['UserID'].

  10. Click OK.
  11. Click OK again to save this Recordset.
  12. Press Ctrl (Cmd) S to save your page.

Step 3: Apply the Show If Utility

This next step utilizes the Show If Utility included in Search for BOSS! another WebAssist extension. This feature allows you to specify content to appear based on certain criteria, such as the result of a Recordset.

  1. Highlight the text you have inserted.
    You might want to use Code view to ensure that you have selected all the necessary tags surrounding this link.
  2. From the Server Behaviors panel, choose Add ( ) > Utilities > Show Region Utility.
  3. Select the If lightning bolt.
  4. Expand the rsDownloadCount Recordset and choose the rsDownloadCount column.

  5. Click OK.
  6. From the Is menu, choose greater than.
  7. In the value field, enter 0.
    This will show the link, only if the result from the Recordset is greater than 0. Therefore, if the product can be downloaded.
  8. Press Ctrl (Cmd) S to save your page.


You've now created your Download Center and tied it into your site by adding a link to the User Profile page.

arrow downWhat to do next...

Now that you have completed creating your Download Center, you may want to spend some time customizing the appearance of the page, and adding additional Recordset bindings to display information from the orders or products tables. When you are finished with your site, you will want to upload everything to your live server and import your database to your live MySQL database so that your online store is on the web.

arrow downReviews and comments

Comments will be sent to the author of this tutorial and may not be answered immediately. For general help from WebAssist, please visit technical support.

Sign in to add comments
rating
rating

victor367017: 3 Years, 10 Months, 2 Weeks, 2 Days, 18 Hours, 32 Minutes ago

If ths is a tutorial then I am Moses. A simple video would work much better

rating

steveni338590: 2 Years, 3 Months, 2 Weeks, 3 Days, 18 Hours, 26 Minutes ago

These tutorials are so far out of date it is ridiculous! Search for BOSS was discontinued years ago. Can you please go through all of these tutorials and bring them up to date. I have seen comments 2 years ago stating that the team was working on updating the tutorials but they are still old.
I don't see how a novice could possibly get half these things working because the only way is to engage with support. Surely it is in everyones interest to ensure the training is up to date and helpful? DMXZone are just as guilty.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.