Computer Science Canada Dynamic WML |
Author: | rdrake [ Tue Nov 15, 2005 7:08 pm ] | ||||||||||||
Post subject: | Dynamic WML | ||||||||||||
So you've read my last tutorial and you want to know, how can I make my pages dynamic? Seeing a page you've created is nice, but what if you could find information from a database? In this tutorial I'll show you how you can acheive this and more. Most importantly, you must insert a header to show the WAP browser that the page is indeed WML. This is accomplished (in PHP) with the following statement.
Now, all we have to do is make sure whatever we output follows the WML syntax, and we'll be fine. Let's say we want to have a form on one page which links to a processing page. We would, of course have to build the page. It would look something like the following.
Like before, we have two input fields. We also have a link, with the text 'OK' which will take us to 'process.php'. It will use the POST method for passing the information. The most important part of the above code is the postfield tag. It passes along the values of the input fields via the POST method and gives them the value $<whatever>. This is the name of the variable we will use to access this information in the next page. Now we will process the code shown above. Our page looks pretty similar at first glance, but it does get quite different. We're using PHP/Ruby to output the examples, so we must output the header.
We can now put the next part in plain text (if using PHP, with Ruby you must use puts). While we're at it, why don't we display the value of the variables?
You can use the above with pretty much and web scripting language, or CGI language. Examples include PHP, Ruby, ASP (if you really must), Pike, PERL, and others. Some applications include fetching information from a database based on user input and displaying it, or even checking flight information or showtimes. I've used it to allow people to search for what time their hockey game is. |