- WML2 - Tutorial
- WML - DTD
- WML - Template
- WML - Timer
- WML - Events
- WML - Server Scripts
- WML - Submit Data
- WML - Inputs
- WML - Tasks
- WML - Links
- WML - Tables
- WML - Images
- WML - Fonts
- WML - Formatting
- WML - Variables
- WML - Comments
- WML - Elements
- WML - Syntax
- WML - Environment
- WML - Overview
- WML - Home
WML References
WML Tools
WML Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
WML - Server Side Scripts
If you already know how to write server side scripts for Web Apppcation, then for you this is very simple to write Server Side program for WML apppcations. You can use your favorite server-side technology to do the processing required by your mobile Internet apppcation.
At the server side, the parameter name will be used to retrieve the form data.
Consider the following example from previous chapter to submit name, age and sex of a person:
<?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml12.dtd"> <wml> <card id="card1" title="WML Form"> <p> Name: <input name="name" size="12"/> Sex : <select name="sex"> <option value="male">Male</option> <option value="female">Female</option> </select> Age : <input name="age" size="12" format="*N"/> <anchor> <go method="get" href="process.php"> <postfield name="name" value="$(name)"/> <postfield name="age" value="$(age)"/> <postfield name="sex" value="$(sex)"/> </go> Submit Data </anchor> </p> </card> </wml>
WML and PHP
Now, we can write a server side script to handle this submitted data in using either PHP, PERL, ASP or JSP. I will show you a server side script written in PHP with HTTP GET method.
Put the following PHP code in process.php file in same directory where you have your WML file.
<?php echo Content-type: text/vnd.wap.wml ; ?> <?php echo <?xml version="1.0"? . > ; ?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml12.dtd"> <wml> <card id="card1" title="WML Response"> <p> Data received at the server:<br/> Name: <?php echo $_GET["name"]; ?><br/> Age: <?php echo $_GET["age"]; ?><br/> Sex: <?php echo $_GET["sex"]; ?><br/> </p> </card> </wml>
If you are using HTTP POST method, then you have to write PHP script accordingly to handle received data. While sending output back to the browser, remember to set the MIME type of the document to "text/vnd.wap.wml".
This way, you can write full fledged Web Apppcation where lot of database transactions are involved.
You can use
to write a dynamic WAP site. Advertisements