SoFunction
Updated on 2025-04-07

WML Learning Seven CGI Programming

CGI Programming
1) Add the MIME type of WML on the WEB server
For IIS4, you can add new MIME type, suffix.wml and MIME type text/ to the site properties in its manager.
For PWS, you can modify the registry, first add the primary key .wml in the HKEY_CLASSES_ROOT layer, then add the string value Content Type to text/, then add the primary key text/ in HKEY_LOCAL_MACHINE\Software\CLASSES\MIME\Database\Content Type\, and then add the string value Extension to .wml.
The HDML mentioned earlier also uses a similar method.
2) Access wml file in http mode
Enter http://localhost/ in the URL bar of your mobile browser to access the WML file.
3) CGI design
It is similar to the way it becomes in normal CGI. However, when returning the result, you must first output Content-Type as text/, and then output WML content.

---------------
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "/DTD/wml_1.">
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=0"/>
</head>
<card >
<do type="accept" label="Input Name" name="do1">
<go href="http://localhost/" method="post">
<postfield name="uid" value="123456"/>
<postfield name="uname" value="$(userName:esc)"/>
</go>
</do>
<p>
NAME:<input name="userName" title="User Name" type="text" format="*M" emptyok="false" maxlength="12"/>
</p>
</card>

---------------
<%
uid=("uid")
userName=("uname")
="text/"
%>
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "/DTD/wml_1.">
<wml>
<card>
<p>
USERNAME:<%=userName%>
USER__ID:<%=uid%>
</p>
</card>
</wml>