Longhorn PHP 2019 Schedule

江苏11选五开奖结果:Dealing with XForms

湖北十一选五官网 www.na503.cn » XForms defines a variation on traditional webforms which allows them to be used on a wider variety of platforms and browsers or even non-traditional media such as PDF documents.

The first key difference in XForms is how the form is sent to the client. » XForms for HTML Authors contains a detailed description of how to create XForms, for the purpose of this tutorial we'll only be looking at a simple example.

Example #1 A simple XForms search form

<h:html xmlns:h="//www.w3.org/1999/xhtml"
        xmlns="//www.w3.org/2002/xforms">
<h:head>
 <h:title>Search</h:title>
 <model>
  <submission action="//example.com/search"
              method="post" id="s"/>
 </model>
</h:head>
<h:body>
 <h:p>
  <input ref="q"><label>Find</label></input>
  <submit submission="s"><label>Go</label></submit>
 </h:p>
</h:body>
</h:html>

The above form displays a text input box (named q), and a submit button. When the submit button is clicked, the form will be sent to the page referred to by action.

Here's where it starts to look different from your web application's point of view. In a normal HTML form, the data would be sent as application/x-www-form-urlencoded, in the XForms world however, this information is sent as XML formatted data.

If you're choosing to work with XForms then you probably want that data as XML, in that case, look in $HTTP_RAW_POST_DATA where you'll find the XML document generated by the browser which you can pass into your favorite XSLT engine or document parser.

If you're not interested in formatting and just want your data to be loaded into the traditional $_POST variable, you can instruct the client browser to send it as application/x-www-form-urlencoded by changing the method attribute to urlencoded-post.

Example #2 Using an XForm to populate $_POST

<h:html xmlns:h="//www.w3.org/1999/xhtml"
        xmlns="//www.w3.org/2002/xforms">
<h:head>
 <h:title>Search</h:title>
 <model>
  <submission action="//example.com/search"
              method="urlencoded-post" id="s"/>
 </model>
</h:head>
<h:body>
 <h:p>
  <input ref="q"><label>Find</label></input>
  <submit submission="s"><label>Go</label></submit>
 </h:p>
</h:body>
</h:html>

Note: As of this writing, many browsers do not support XForms. Check your browser version if the above examples fails.

add a note add a note

User Contributed Notes 3 notes

up
14
lphuberdeau at phpquebec dot org
14 years ago
Since HTTP_RAW_POST_DATA requires a configuration to be generated and is not enabled as a default value, you will probably have to use the PHP STDIN stream to get the raw data. It's probably better to use this method as the raw data will not be generated every time, even when not needed.

<?php
$fp
= fopen( "php://stdin", "r" );
$data = '';
while( !
feof( $fp ) )
   
$data .= fgets( $fp );
fclose( $fp );
?>
up
5
OrionI
13 years ago
FireFox has an XForms plugin that works with the latest nightly builds. Check out //www.mozilla.org/projects/xforms/ for more info. For IE support, there's an ActiveX control from Novell (//developer.novell.com/xforms/) and one from x-port.net (//www.formsplayer.com/).

There's also a JavaScript-based one coming out called FormFaces which looks very promising, especially since there are no plugins required and it works in IE, FF, and Opera: //www.formfaces.com/
up
-2
Darkener Daemon EX
13 years ago
"php://stdin" doesn't exist in my PHP version. I use the following code block instead :
<?php
if (!isset($HTTP_RAW_POST_DATA))
   
$HTTP_RAW_POST_DATA = file_get_contents("php://input");
?>
To Top
  • 股票买卖中不可忽略的大宗交易数据(上) 2019-02-19
  • "央企暖男"与108名抗战老兵:向他们致以年轻一代的敬意 2019-02-19
  • 学生补课累到不行 网友:节假日都不休息 2019-02-19
  • 世界杯期间夜猫子吃什么好 这是有讲究的 2019-02-19
  • 一切腐败分子和一切为钱的各种违法犯罪高发:1、不是来自从无偿占有一个鸡蛋私心开始,而是从私有制社会存开始,因为占有他人一个鸡蛋的私有观念欲望,是从社会存在产生派 2019-02-18
  • 推进58个重点项目 杭州加快钱塘江金融港湾建设 2019-02-18
  • 高清:C罗帽子戏法科斯塔梅开二度 葡萄牙3 2019-02-18
  • 美国再挑贸易战,中方强力回击,全球市场跌声一片 2019-02-17
  • 内政部长威胁“单飞”,联盟党闹分裂,默克尔或下台? 2019-02-17
  • 看来“无名小卒也”这样的网民在公有制企业里有一大批,那么公有制企业一定会发展的快,搞的好,呵呵。 2019-02-17
  • 视频:太原蒙山景区举办首届蒙山春节庙会 2019-02-16
  • 习近平会见美国国务卿蓬佩奥 2019-02-16
  • [酷]中国天翻地复的变化确实惊人 2019-02-15
  • 王烜:当心单边主义在全球圈粉 2019-02-15
  • 端午假期虎门大桥最易拥堵 2019-02-15
  • 7| 164| 220| 356| 126| 943| 621| 963| 977| 907|