home

Softsteel Solutions

About Us Contact Us Newsletter Training
Tutorials
 

Lesson 11: Passing values from pages using POST and GET

As stated in lesson 9 data to be passed using the go command are given as variables in special 'postfield' elements. These postfield elements are always empty (ie they don't take a separate closing tag) and have two required attributes: 'name' and 'value'. To take an example of these attributes: the following postfield element specifies the value 'hello' for the datum 'greeting'.

<postfield name="greeting" value="hello"/>

The postfield elements are held within opening and closing 'go' tags, and the 'method' attribute of the the go element specifies the manner in which the elements are sent. The following code sends the password value 'hi', using the 'get' method, to deck2.wml.

1.

<go href="deck2.wml" method="get">

2.

<postfield name="password" value="hi"/>

3.

</go>

There are two possible method used to pass data in this way. One is 'get', as used above, the other is 'post'. Using the 'get' method, the data passed actually piggy-backs on the address (URL) of the recipient. The following URL shows how the datum specified above would be passed to deck2.wml:

deck2.wml?password=hi

The get method has two weaknesses. The first is that it is easier for an external person to capture data sent in this way. The second is that there is a tight limit to the amount of information sent (typically 127 characters).

Using the alternative 'post' method, the data are sent in the body of the message. This is more secure than the 'get' method, and more data can be sent in this way. However, at the time of writing 'get' is more widely supported by gateways than 'post'.

Note that because of the way in which 'get' variables are actually sent, one can also send these variables by appending them manually to the end of the url specified in the 'href' attribute of the go element. For instance, the following code sends two pieces of data, dataOne and dataTwo, and each via the 'get' method.

1.

<go href="deck2.wml?dataOne=one" method="get">

2.

<postfield name="dataTwo" value="two"/>

3.

</go>

 

WML Tutorials