Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 1915

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Dealing with XForms</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="features.sessions.html">Sessions</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="features.file-upload.html">Handling file uploads</a></div>
 <div class="up"><a href="features.html">Features</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="features.xforms" class="chapter">
 <h1>Dealing with XForms</h1>

 <p class="para">
  <a href="http://www.w3.org/MarkUp/Forms/" class="link external">&raquo;&nbsp;XForms</a> 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.
 </p>
 <p class="para">
  The first key difference in XForms is how the form is sent to the client.
  <a href="http://www.w3.org/MarkUp/Forms/2003/xforms-for-html-authors.html" class="link external">&raquo;&nbsp;<em>XForms for HTML Authors</em></a>
  contains a detailed description of how to create XForms, for the purpose
  of this tutorial we&#039;ll only be looking at a simple example.
 </p>
 <div class="example" id="example-354">
  <p><strong>Example #1 A simple XForms search form</strong></p>
  <div class="example-contents">
<div class="htmlcode"><pre class="htmlcode">&lt;h:html xmlns:h=&quot;http://www.w3.org/1999/xhtml&quot;
        xmlns=&quot;http://www.w3.org/2002/xforms&quot;&gt;
&lt;h:head&gt;
 &lt;h:title&gt;Search&lt;/h:title&gt;
 &lt;model&gt;
  &lt;submission action=&quot;http://example.com/search&quot;
              method=&quot;post&quot; id=&quot;s&quot;/&gt;
 &lt;/model&gt;
&lt;/h:head&gt;
&lt;h:body&gt;
 &lt;h:p&gt;
  &lt;input ref=&quot;q&quot;&gt;&lt;label&gt;Find&lt;/label&gt;&lt;/input&gt;
  &lt;submit submission=&quot;s&quot;&gt;&lt;label&gt;Go&lt;/label&gt;&lt;/submit&gt;
 &lt;/h:p&gt;
&lt;/h:body&gt;
&lt;/h:html&gt;</pre>
</div>
  </div>

 </div>
 <p class="para">
  The above form displays a text input box (named <em><code class="parameter">q</code></em>),
  and a submit button.  When the submit button is clicked, the form will be
  sent to the page referred to by <em>action</em>.
 </p>
 <p class="para">
  Here&#039;s where it starts to look different from your web application&#039;s point
  of view.  In a normal HTML form, the data would be sent as 
  <em>application/x-www-form-urlencoded</em>, in the XForms world
  however, this information is sent as <acronym title="eXtensible Markup Language">XML</acronym> formatted data.
 </p>
 <p class="para">
  If you&#039;re choosing to work with XForms then you probably want that data as
  <acronym title="eXtensible Markup Language">XML</acronym>, in that case, look in <var class="varname"><var class="varname"><a href="reserved.variables.httprawpostdata.html" class="classname">$HTTP_RAW_POST_DATA</a></var></var> where
  you&#039;ll find the <acronym title="eXtensible Markup Language">XML</acronym> document generated by the browser which you can pass
  into your favorite <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> engine or document parser.
 </p>
 <p class="para">
  If you&#039;re not interested in formatting and just want your data to be loaded
  into the traditional <var class="varname"><var class="varname"><a href="reserved.variables.post.html" class="classname">$_POST</a></var></var> variable, you can instruct
  the client browser to send it as <em>application/x-www-form-urlencoded</em>
  by changing the <em><code class="parameter">method</code></em> attribute to
  <em class="emphasis">urlencoded-post</em>.
 </p>
 <div class="example" id="example-355">
  <p><strong>Example #2 Using an XForm to populate <var class="varname"><var class="varname"><a href="reserved.variables.post.html" class="classname">$_POST</a></var></var></strong></p>
  <div class="example-contents">
<div class="htmlcode"><pre class="htmlcode">&lt;h:html xmlns:h=&quot;http://www.w3.org/1999/xhtml&quot;
        xmlns=&quot;http://www.w3.org/2002/xforms&quot;&gt;
&lt;h:head&gt;
 &lt;h:title&gt;Search&lt;/h:title&gt;
 &lt;model&gt;
  &lt;submission action=&quot;http://example.com/search&quot;
              method=&quot;urlencoded-post&quot; id=&quot;s&quot;/&gt;
 &lt;/model&gt;
&lt;/h:head&gt;
&lt;h:body&gt;
 &lt;h:p&gt;
  &lt;input ref=&quot;q&quot;&gt;&lt;label&gt;Find&lt;/label&gt;&lt;/input&gt;
  &lt;submit submission=&quot;s&quot;&gt;&lt;label&gt;Go&lt;/label&gt;&lt;/submit&gt;
 &lt;/h:p&gt;
&lt;/h:body&gt;
&lt;/h:html&gt;</pre>
</div>
  </div>

 </div>
 <blockquote class="note"><p><strong class="note">Note</strong>: 
  <span class="simpara">
   As of this writing, many browsers do not support XForms.
   Check your browser version if the above examples fails.
  </span>
 </p></blockquote>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="features.sessions.html">Sessions</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="features.file-upload.html">Handling file uploads</a></div>
 <div class="up"><a href="features.html">Features</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>