#native_company# #native_desc#
#native_cta#

Building WML Sites Page 3

By Andres Baravalle
on February 21, 2001

Writing PHP/WML code

Now we write our first PHP/WML
page which we call index.wml

<?php

Header("Content-type: text/vnd.wap.wml");

Header("Cache-Control: no-cache, must-revalidate");

Header("Pragma: no-cache");

echo (
"<?xml version='1.0'?>");

?> 

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"

    "http://www.wapforum.org/DTD/wml_1.1.xml" > 

<wml> 

<card id="card1" title="UNITO/Database"> 

<p> You can search for professors' consulting hours

  or for examinations timetables.

  <select name="choice" value="1" title="Research"> 

    <option value="exams_data">Examinations timetables</option> 

    <option value="consulting_data">Consulting hours</option> 

  </select> 

  <do type="text" label="Go"> 

  <go method="get" href="index2.wml#card2"> <postfield name="choice" value="$(choice)" /> </go> 

  </do> 

</p> 

</card> 

</wml> 


The first line tells the browser
accessing the page what kind of MIME type are sent.
Without the header command, the browser could not
understand what kind of content is coming. Moreover,
with this line you are not forced to set a particular
extension for your files. This is very useful if
you plan to write multimodal pages, with a script
that checks the device or its capabilities and returns
WML or HTML according to the type of browser.
Check whether PHP is installed
with short tags enabled. If yes, every time you write
a declaration like <?xml
version='1.0'?>,
embed it into PHP code
to avoid confusion.
The rest of the code of this
page simply lets you search for examinations timetables
or consulting hours. The choice is recorded into
variable $choice.