WAD
Passing Data With Forms
When we process forms we have a choice of methods from which we can utilise to pass our data from the form page to the response. The response is the page that does all the work and it need not even be a separate page, it can be the same page that looks for a variable before deciding how it will react to the incoming information.
We do not want to busy ourselves with that at the moment though, we are going to look fairly and squarely at the methods that are used for passing data from the form page to the response page.
Data transfer methods
- Our first option is the Post method
- The second option is the Get method
We can set these values from the Property Inspector, but first we must select the form tag in Dreamweaver MX's quick tag selector as shown in Fig 1.
Fig 1
![]()
Selecting our form will put the property inspector in to form mode, it should look like Fig 2.
Fig 2

We can clearly see the options available in the Method drop list as I have activated the list and it is ready to accept our choice of method. You will notice that three options are available and not two as the tutorial suggested at the beginning, the default option is not a very efficient method as both the post and the get methods are checked for in this mode, resulting in twice the work in processing the form.
The first method we will explore is the post method, this method sends the data from the form within the body of the processing agent. This makes the post method secure and reliable when sending what might be sensitive data from one location to another.
The second method of get attaches the information to the URL and passes the information in a manner that can be seen by the user so is therefore not a secure method of passing sensitive data. This method also carries a restriction on the amount of data that can be transferred, it is a reasonable amount of data but restricted none the less.
If you are having problems passing data between pages using a form you can change the method from post to get while you test, this will enable you to see the information as it's passed and may just show the error you are looking for. Remember if it's sensitive information to change it back to post.
Let's take a look at the rest of the PI in form mode
FormName
We have the form name box, by default Dreamweaver MX gives all our forms a name, this is totally correct, they should be named. As you can see the default name given to our form is form1, if we don't change that and add a second form Dreamweaver MX will name it form2, I guess you can see the pattern forming here. The default names are fine but to make them easier to identify in code view it can help to give them meaningful names.
Action
The action box allows you to browse to the file we wish to use as our form response page, click on the folder and you will be able to navigate to, and select, the required file.
Target
Should you be working in a frameset the target select list will allow you to choose which frame you are targeting when you pass the data. To enable the selection of the frame from the property inspector you must have the frameset open in Dreamweaver MX at the time you are making the selection.
Enctype
The first option is the application/x-www-form-urlencoded. This is used in conjunction with the get method, you cannot send files using this method and it has the security problems we touched on earlier. This would pass the variables in the URL in a manner like the link in example1. In this instance the URL is passing the form variables FirstName and LastName in the URL. As you can see the variables are separated from the URL by a ? and then they are concatenated with the &, this is known as a query string.
Example1
http://www.mydomain.com/mypage.cfm?FirstName=David&LastName=Smith
If you want your pages to validate to the xhtml standard you should replace the & with &
The second option is multipart/formdata we would typically use this option when setting up an upload facility, using multipart/formdata we can transfer files from our hard drive to our web site or other places on the Internet.
You will notice that the enctype list also has a blank option, you can use this option when setting the method to post as we are neither appending info to the URL or trying to upload files to a server.
I hope that has given you an insight into the different ways we can pass data using forms, the reasons why we want to pass data in forms can vary from sending a simple email to writing information into a database. Whatever the reason we are using our form for the basics are the same.
No comments:
Post a Comment