跳转到内容

XQuery/基础反馈表格

来自维基教科书,开放世界中的开放书籍

您希望收集访客的反馈。

一个简单的 HTML 表单收集建议的改进和电子邮件地址。建议将发送给作者之一,并向提交者发送确认信息。这里使用 UWE 布里斯托尔 eXist 实现上的默认邮件发送客户端。

XQuery 脚本

[编辑 | 编辑源代码]
xquery version "1.0";
 
(: A simple Feedback form using the eXist mail module :)
 
import module namespace mail="http://exist-db.org/xquery/mail";
declare option exist:serialize "method=xhtml media-type=text/html";

let $comment:= normalize-space(request:get-parameter("comment",""))
let $email := normalize-space(request:get-parameter("email",""))
return 
<html>
  <head>
    <title>Feedback on the XQuery Wikibook</title>
  </head>
  <body>
   <h1>Feedback on the XQuery Wikibook</h1>
   <form method="post">
     Please let us know how this Wikibook could be improved.<br/>
     <textarea name="comment" rows="5" cols="80"/><br/>
     Your email address <input type="text" name="email" size="60"/>
     <input type="submit" value="Send"/>
  </form>
  {if ($email ne "" and $comment ne "")
  then 
      let $commentMessage :=
  <mail>
    <from>{$email}</from>
    <to>[email protected]</to>
    <subject>Wikibook Feedback</subject>
    <message>
      <text>{$comment}</text>
    </message>
  </mail>
      let $ackMessage := 
   <mail>
    <to>{$email}</to>
    <from>[email protected]</from>
    <subject>Wikibook Feedback</subject>
    <message>
      <text>Many thanks for your feedback - we appreciate your interest in this collaborative work.</text>
    </message>
  </mail>
     let $sendcomment := mail:send-email($commentMessage,(),())
     let $sendack := mail:send-email($ackMessage,(),())
     return
       if ($sendcomment and $sendack)
       then 
         <div>
           <h2>Feedback</h2>
           <p>You suggested that the XQuery Wikibook could be improved by:<br/>
           <em>{$comment}</em>.  
           <br/>Thanks for the feedback.</p>
         </div>
       else 
         <p>Something went wrong - please try again</p>
    else
    if ($comment ne "")
    then <div>Please provide an email address so that we can let you know of progress on your suggestion.</div>
    else 
    ()
    }
  </body>
</html>

反馈表格

华夏公益教科书