Tutorial
"Test Address": http://wap.blueidea.com/tutorial/wapguestbook/
Admin Address: http://wap.blueidea.com/tutorial/wapguestbook/admin.asp
Please test when you do not enter the illegal and reactionary information, otherwise I will only delete the test file, thank you for your cooperation.
Test tools: WAP simulator (such as opera,m3gate, etc.), support WAP mobile phone.
I've always had friends in the Chinese variable transmission of WAP encountered problems, here give a simple WAP message this production process, but also solve the Chinese transmission of WAP problem.
WAP sites are similar to traditional web sites, as well as PC computers for backstage management. The only difference is that one is browsing with a mobile phone, and one is browsing with a computer. The foreground display page uses the handset to browse, the Backstage management page uses the IE browser to carry on the view, the management can.
If you have been able to write a simple message this program, then the production of WAP message has been very simple things, but only to the HTML into WML so simple, as for the WML syntax, see the tutorial will be more simple than HTML, specific tutorials Google.
Some WAP tutorials.
Www.itsalon.net/wap/
WWW.WAPEASE.COM/CLASS/TIP2/
Tech.sina.com.cn/wap/school/index.shtml
Look for the rest yourself.
The procedure of this message includes: Post, save, display, edit, reply, delete.
The entire background management + foreground display, also on these several functions.
Note: The following code, if you are writing using EditPlus, please choose to save as "UTF-8" encoding. If you do not, you will encounter a WML in the transfer of Chinese variables, there are garbled problems.
Take the example of ASP. So let's start with the posting page, add.asp.
Specify the script and encoding used for ASP pages, codepage= "65001" This must not be less, is to represent UTF-8 encoding, GB2312 is codepage= "936".
% @LANGUAGE = "VBSCRIPT" codepage= "65001"%
Make a reputation for WML header file information so that even if you're using virtual space, you don't have to map mime file types in IIS or Apache.
<% response.contenttype= "Text/vnd.wap.wml;charset=utf-8"%>
The name WML header file information, this is the stipulation, has stipulated the WAP version and the adoption standard, if does not understand then writes on the line, does not change, but must add. Where encoding is also the specified encoding.
<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en" "Http://www.wapforum.org/DTD/wml_1.1.xml" >
The next step is the display code for the page.
<card id= "Add" title= "Classic WAP message book" >
<p>
Nickname:<br/>
<input name= "name" emptyok= "false" size= "a" maxlength= "ten"/><br/>
Title:<br/>
<input name= "Title" emptyok= "false" Maxlength= "/><br/>"
Content:<br/>
<input name= "Content" format= "false" Maxlength= "/><br/>"
</p>
</card>
A brief introduction: WML is similar to HTML tags, card represents a cards, here simply understood as a page on the line, note: All the display content should be placed in the <p> </p> tag, must pay attention to this, or you will be wrong.
<meta http-equiv= "Cache-control" content= "max-age=0"/>
<meta http-equiv= "Cache-control" content= "No-cache"/>
Specifies that the page is not cached in Meta.
<input name= "Title" emptyok= "false" Maxlength= "/><br/>"
Emptyok is not allowed to be empty, maxlength allows the maximum length of text to be entered.
WML form submission is somewhat different, <postfile name= "title" Value= "($title: N)"/> is to attach the value of the input form to the title variable, name= "title" is the variable name, value= "($ TITLE:N) "is the variable, that is, the information entered in input, content is the same.
Note: here ($title: N) is the wording of the WML variable, at the beginning of the $ symbol, PHP-like variable reputation, in WML form submission has: N,:e,:u, and null, four states, where: N is forced to do not URL escape;: E is escaped;: U is reverse; On some mobile phones, the default is not escaped, some escape, the specification is not unified, safe period, if not escaped, or write: N for good.
WAP variable submission is also divided into two cases, get and post, using the Get method, the Chinese support is not very good, so there are use to the form submission, the Post method is submitted, the code format is:
<anchor>post Way to submit
<go href= "save.asp" method= "POST" >
<postfield name= "Name" value= "$ (name:n)"/>
<postfield name= "Title" value= "$ (title:n)"/>
<postfield name= "Content" value= "$ (content:n)"/>
<postfield name= "Method" value= "POST"/>
</go>
</anchor>
Of course for English and digital, simple, use Get method submission will be more convenient, the code format is:
<a href= "save.asp? name=$ (name:n) &title=$ (title:n) &content=$ (content:n) &method=get ">get method submission </a>
Note: & symbols for connecting different variable characters should be written as &
Post the Message page add.asp code as follows:
<% @LANGUAGE = "VBSCRIPT" codepage= "65001"%>
<% response.contenttype= "Text/vnd.wap.wml;charset=utf-8"%>
<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en" "Http://www.wapforum.org/DTD/wml_1.1.xml" >
<wml>
<meta http-equiv= "Cache-control" content= "max-age=0"/>
<meta http-equiv= "Cache-control" content= "No-cache"/>
<card id= "Add" title= "Classic WAP message book" >
<p>
Nickname:<br/>
<input name= "name" emptyok= "false" size= "a" maxlength= "ten"/><br/>
Title:<br/>
<input name= "Title" emptyok= "false" Maxlength= "/><br/>"
Content:<br/>
<input name= "Content" format= "false" Maxlength= "/><br/>"
<br/><anchor>post Way to submit
<go href= "save.asp" method= "POST" >
<postfield name= "Name" value= "$ (name:n)"/>
<postfield name= "Title" value= "$ (title:n)"/>
<postfield name= "Content" value= "$ (content:n)"/>
<postfield name= "Method" value= "POST"/>
</go>
</anchor>
<br/><a href= "save.asp? name=$ (name:n) &title=$ (title:n) &content=$ (content:n) &method=get ">get method submission </a><br/> <br/>
<a href= "index.asp" > Return to Message list </a>
</p>
<p>
If you have any questions, please visit: http://www.designer5.net or <br/>
Blue Ideal Forum WAP version:http://www.blueidea.com/bbs<br/>
Advertisement: The Blue Ideal WAP website revision, uses the handset to visit <a href= "http://wap.blueidea.com
Http://wap.blueidea.com ">http://wap.blueidea.com</a><br/>
If you refer to this program, there is a WAP site, please do a http://wap.blueidea.com link.
</p>
<do type= "prev" label= "Back" ><prev/></do>
</card>
</wml>
The next step is to save the data.
Save the page save.asp, the code is as follows:
<% @LANGUAGE = "VBSCRIPT" codepage= "65001"%>
<!--#include file= "conn.asp"-->
<%
Function INWML (str)
' Store string in database, single quote filter, ' ==CHR (39)
Stemp = Replace (str, CHR (39), "'") ' single quote filter
INWML = stemp
End Function
IF Request ("method") <> "Then
NAME=INWML Trim (Request ("Name"))
TITLE=INWML (Request ("Title"))
CONTENT=INWML (Request ("Content"))
Method=request ("Method")
SQL = "INSERT into guestbook (Name, Title, Content, method) VALUES (' &Name& ', '" &Title& "', '" & content& "', '" &Method& ")"
Conn.execute SQL
End IF
Response.Redirect ("index.asp")
%>
Finally, show the content of the message displayed.
You need to pay attention to the substitution of characters when displaying data. Because some characters are not directly displayed, need to convert to ASCII, in WML "$" symbol is a variable, if you want to display "$", you need to write "$$", for example: "There is a total of $$315 yuan RMB", shown as "altogether $ 315 Yuan RMB ".
Must be replaced by characters that have been written as functions that are convenient for everyone to use.
Function outhtm (str)
' The string is encoded in HTM, the output string
Dim stemp
Stemp = str
outhtm = ""
If IsNull (stemp) Then
Exit Function
End If
Stemp = Replace (stemp, "'", "'") ' Restore single quotes
Stemp = Replace (Stemp, "&", "&")
Stemp = Replace (Stemp, "<", "<")
Stemp = Replace (stemp, ">", ">")
Stemp = Replace (stemp, "$", "$$")
Stemp = Replace (stemp, "", "")
Stemp = Replace (Stemp, Chr (), "<br/>")
outhtm = stemp
End Function
Display the Message page index.asp, the code is as follows:
<% @LANGUAGE = "VBSCRIPT" codepage= "65001"%>
<!--#include file= "conn.asp"-->
<%
Function outhtm (str)
' The string is encoded in HTM, the output string
Dim stemp
Stemp = str
outhtm = ""
If IsNull (stemp) Then
Exit Function
End If
Stemp = Replace (stemp, "'", "'") ' Restore single quotes
Stemp = Replace (Stemp, "&", "&")
Stemp = Replace (Stemp, "<", "<")
Stemp = Replace (stemp, ">", ">")
Stemp = Replace (stemp, "$", "$$")
Stemp = Replace (stemp, "", "")
Stemp = Replace (Stemp, Chr (), "<br/>")
outhtm = Stemp End Function
SQL = "SELECT * from Guestbook ORDER by ID DESC"
Set Rs = Server.CreateObject ("Adodb.recordset")
Rs.Open sql,conn,1,3
page = request.querystring ("page")
Rs.pagesize = 6 ' one page 6 records
IF not IsEmpty (Page) Then
If not IsNumeric (page) Then ' Determines whether the page is a number
Page=1
Else
Page=cint (Page) ' converted to short integer
End IF
IF Page > Rs.pagecount Then
Rs.absolutepage = Rs.pagecount ' Set current display page equals last page
ElseIF Page <= 0 Then
Rs.absolutepage = 1 ' Set current page equals first page
Else
rs.absolutepage = Page ' If greater than 0, display the current page equals the number of pages received
End IF
Else
Rs.absolutepage = 1
End IF
Page = Rs.absolutepage
%>
<% response.contenttype= "Text/vnd.wap.wml;charset=utf-8"%>
<?xml version= "1.0" encoding= "Utf-8"? ><! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en" "Http://www.wapforum.org/DTD/wml_1.1.xml" >
<wml>
<meta http-equiv= "Cache-control" content= "max-age=0"/>
<meta http-equiv= "Cache-control" content= "No-cache"/>
<card id= "Add" title= "Classic WAP message book" >
<p>
<a href= "add.asp" > Publishing New Stickers </a><br/>
<%
For I=1 to Rs.pagesize
If rs.eof Then
Response.Write "There's no message!" <br/> "
Exit for
End If
%>
(<%=rs ("ID")%>) <%=outhtm (Rs ("Title")%><br/>
Content: <%=outhtm (Rs ("Content"))%><br/>
Message person: <%=outhtm (Rs ("Name"))%><br/>
Time: <%=outhtm (Rs ("Creattime"))%><br/>
Reply: <%
If Rs ("Reply") <> "then"
Response.Write outhtm (Rs ("Reply"))
Else
Response.Write "" No Reply ""
End If
%><br/>
------<br/>
<%
Rs.movenext
Next
If Page>=rs.pagecount Then
' Response.Write ([next page]]
Else
Response.Write ("[<a href= ' index.asp?") Page= "& (page+1) &" ' > Next page </a>] "
End If
If Page<=1 Then
' Response.Write ([prev]]
Else
Response.Write ("[<a href= ' index.asp?") Page= "& (Page-1) &" ' > Prev </a>] "
End If
%>
<br/><a href= "add.asp" > Publishing New Stickers </a>
</p>
<p>
If you have any questions, please visit: http://www.designer5.net or <br/>
Blue Ideal Forum WAP version:http://www.blueidea.com/bbs<br/>
Advertisement: Blue Ideal WAP website revision, <a href= "http://wap.blueidea.com
Http://wap.blueidea.com ">http://wap.blueidea.com</a><br/>
If you have a WAP site and refer to this program, please make a http://wap.blueidea.com connection
</p>
</card>
</wml>
Admin page admin.asp, code as follows:
<% @LANGUAGE = "VBSCRIPT" codepage= "65001"%>
<!--#include file= "conn.asp"-->
<%
Function INWML (str)
' Put the string into the database, single quote filter
Stemp = Replace (str, CHR (39), "'") ' single quote filter
INWML = stemp
End Function
IF (Request.Form ("Flag") = "Replysave") Then
id = request.form ("id")
Name = INWML (Request.Form ("name"))
title = INWML (Request.Form ("title"))
Content = INWML (Request.Form ("content"))
Reply = INWML (Request.Form ("Reply"))
' User comments can be modified to prevent users from entering illegal information
SQL = "UPDATE Guestbook SET Name = ' &Name& '", "
sql = sql + "Title = '" &Title& "", "
sql = sql + Content = ' &Content& ', '
sql = sql + "Reply = '" &Reply& ""
sql = SQL + "WHERE Id =" &id
Conn.execute SQL
Conn.close
Set Conn = Nothing
Response.Redirect ("admin.asp")
End IF
IF (Request.QueryString ("Action") = "Del") Then
SQL = "DELETE from guestbook WHERE id=" & Request.QueryString ("Id")
Conn.execute SQL
Conn.close
Set Conn = Nothing
Response.Redirect ("admin.asp")
End IF
%>
<%
Set rs=server.createobject ("ADODB. Recordset ")
SQL = "SELECT * from Guestbook ORDER by Id Desc"
Rs.Open sql,conn,3,3
page = request.querystring ("page")
Rs.pagesize = 10 ' one page 6 records
IF not IsEmpty (Page) Then
If not IsNumeric (page) Then ' Determines whether the page is a number
Page=1
Else
Page=cint (Page) ' converted to short integer
End IF
IF Page > Rs.pagecount Then
Rs.absolutepage = Rs.pagecount ' Set current display page equals last page
ElseIF Page <= 0 Then
Rs.absolutepage = 1 ' Set current page equals first page
Else
rs.absolutepage = Page ' If greater than 0, display the current page equals the number of pages received
End IF
Else
Rs.absolutepage = 1
End IF
Page = Rs.absolutepage
%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title> Classic WAP Message book </title>
<style type= "Text/css" >
Body, td{font-size:12px;}
p{line-height:22px;}
</style>
<script language= "javascript" type= "Text/javascript" charset= "Utf-8" >
<!--
function Check_form1 ()
{
if (document.form1.reply.value== "") {
Alert ("Please fill in the reply content!") ");
Document.form1.Reply.focus ();
}
Else{return true;}
return false;
}
-->
</script>
<body>
<table width= "border=" 0 "align=" center "cellpadding=" 1 "cellspacing=" 1 "bgcolor=" #2D96FF ">
<TR align= "center" bgcolor= "#D0E8FF" >
<TD height= "colspan=" "8" ><p><strong> Classic WAP message book </strong></p>
<p><strong> production: </strong><strong><a href= "http://www.designer5.net" target= "_blank" > d5s Studio </a> Author:yytcpt</strong></p>
</td>
</tr>
<TR align= "center" bgcolor= "#9BCDFF" >
<TD height= "><strong>ID</strong></td>"
<td><strong> Message Person </strong></td>
<td><strong> title </strong></td>
<td><strong> Message Content </strong></td>
<td><strong> Submitting Method </strong></td>
<td><strong> Message Time </strong></td>
<TD width= ><strong> reply </strong></td>
<td><strong> Delete </strong></td>
</tr>
<%
For I=1 to Rs.pagesize
If rs.eof Then
Exit for
End If
%>
<tr bgcolor= "#C8E3FF" >
<TD width= "height=" align= "Center" ><%=rs ("Id")%></td>
<TD width= "align=" "Center" ><%=rs ("Name")%></td>
<TD width= "align=" "Center" ><%=rs ("Title")%></td>
<TD width= "247" align= "left" ><%=rs ("Content")%> </td>
<TD width= align= "center" ><%=rs ("method")%></td>
<TD width= "align=" "Center" ><%=rs ("Creattime")%></td>
<TD align= "center" ><a href= "admin.asp?" Action=reply&id=<%=rs ("Id")%> "> Reply </a></td>
<TD width= "align=" center "><a href=" javascript:if (' Do you want to delete it? ') Location= ' admin.asp? Action=del&id=<%=rs ("Id")%> ' "> Delete </a></td>
</tr>
<%
Rs.movenext
Next
%>
<TR align= "center" bgcolor= "#9BCDFF" >
<TD height= "colspan=" 8 ">
<%
Response.Write ("<form name=page method=get onsubmit=" "document.location = ' admin.asp?" Page= ' +this.page.value;return false; "" > ")
If Page<=1 Then
Response.Write ("[Home] [prev]")
Else
Response.Write ("[<a href=admin.asp?") Page=1> home </a>] "
Response.Write ("[<a href=admin.asp?") Page= "& (Page-1) &" > Prev </a>] "
End If
If Page>=rs.pagecount Then
Response.Write ("[Next page] [last]")
Else
Response.Write ("[<a href=admin.asp?") Page= "& (page+1) &" > Next page </a>] "
Response.Write ("[<a href=admin.asp?") Page= "& Rs.pagecount &" > Last </a>] "
End If
Response.Write ("[Page: <font color=red>" & Page & "</font>/" & Rs.pagecount)
Response.Write ("] [Total" & Rs.recordcount & "<font color=red>" & rs.pagesize & "</font>/page]")
Response.Write ("Go" & "<input name=page size=4 value=" & Page & ">" & "Page <input type=submit value =go></form> ")
%>
</td>
</tr>
<TR align= "center" >
<TD height= colspan= "8" bgcolor= "#C8E3FF" ><p> have any questions, please visit <a href= "http://www.designer5.netHttp://www.designer5.net "> <strong>http://www.designer5.net</strong></a> or <strong> <a href= "Http://www.blueidea.com/bbs" target= "_blank" > </a></strong><a href= "http://" Www.blueidea.com/bbs "target=" _blank "><strong> </strong></a><strong><a href=http:// Www.blueidea.com/bbs target= "_blank" > Blue Ideal Forum WAP edition </a></strong><br/>
<strong> advertisement:</strong> Blue Ideal WAP website revision, please use the mobile phone to visit <a href= "http://wap.blueidea.com
Http://wap.blueidea.com "><strong>http://wap.blueidea.com</strong></a><br/>
If you have a WAP site and refer to this program, please make a http://wap.blueidea.com connection </p></td>
</tr>
</table>
<p> </p>
<%
IF (Request.QueryString ("Action") = "Reply") Then
Set rs=server.createobject ("ADODB. Recordset ")
SQL = "SELECT * FROM guestbook WHERE id =" &request.querystring ("id")
Rs.Open sql,conn,3,3
%>
<table width= "333" border= "0" align= "center" cellpadding= "0" cellspacing= "0" bgcolor= "#C8E3FF" >
<form name= "Form1" method= "Post" action= "admin.asp" >
<tr>
<TD width= "><strong>ID</strong></td>"
<TD width= "264" ><%=rs ("Id")%></td>
</tr>
<tr>
<td><strong> Message Person </strong></td>
<td>
<input name= "name" type= "text" value= "<%=rs (" name ")%>" size= ">
</td>
</tr>
<tr>
<td><strong> title </strong></td>
<td><input name= "title" type= "text" value= "<%=rs (" title ")%>" size= "></td>
</tr>
<tr>
<td><strong> Message Time </strong></td>
<td><%=rs ("Creattime")%></td>
</tr>
<tr>
<td><strong> Message Content </strong></td>
<td><textarea name= "Content" cols= "the" rows= "4" ><%=rs ("content")%></textarea></td>
</tr>
<tr>
<td><strong> Site Reply </strong></td>
<td><textarea name= "Reply" cols= "rows=" "4" ><%=rs ("Reply")%></textarea></td>
</tr>
<TR align= "center" >
<TD colspan= "2" ><input type= "Submission" name= "submit" value= "submitted" >
<input type= "reset" name= "Submit" value= "reset" >
<input name= "id" type= "hidden" value= "<%=rs (" Id ")%>" >
<input name= "Flag" type= "hidden" value= "Replysave" >
</td>
</tr>
</form>
</table>
<% End IF%>
</body>
<%
Rs.close
Set Rs = Nothing
%>
Connect the database conn.asp, the code is as follows:
<%
Dim Conn, strSQL
strSQL = "Provider=Microsoft.Jet.OLEDB.4.0" & "Data Source =" & Server.MapPath ("D5s.mdb")
Set Conn = Server.CreateObject ("Adodb.connection")
Conn.Open strSQL
%>
Source Download Address: Click to download
Other Notes: have any questions, please visit:http://www.designer5.net or
Blue Ideal Forum WAP version: Http://www.blueidea.com/bbs
Advertisement: The Blue Ideal WAP website revision, uses the handset to visit http://wap.blueidea.com
If you refer to this program, there is a WAP site, please do a http://wap.blueidea.com link.