downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/features.xforms.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/features.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'features.xforms.php',
   
1 => 'Dealing with XForms',
  ),
 
'up' =>
  array (
   
0 => 'features.php',
   
1 => 'Features',
  ),
 
'prev' =>
  array (
   
0 => 'features.sessions.php',
   
1 => 'Sessions',
  ),
 
'next' =>
  array (
   
0 => 'features.file-upload.php',
   
1 => 'Handling file uploads',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div>
 <h1>Dealing with XForms</h1>

 <p class="para">
  <a href="http://www.w3.org/MarkUp/Forms/" class="link external">&raquo; 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; <i>XForms for HTML Authors</i></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">
  <p><b>Example #1 A simple XForms search form</b></p>
  <div class="example-contents programlisting">
<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 <i><tt class="parameter">q</tt></i>
),
  and a submit button.  When the submit button is clicked, the form will be
  sent to the page referred to by <i>action</i>.
 </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
  <i>application/x-www-form-urlencoded</i>, 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"><a href="reserved.variables.httprawpostdata.php" class="classname">$HTTP_RAW_POST_DATA</a></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"><a href="reserved.variables.post.php" class="classname">$_POST</a></var> variable, you can instruct
  the client browser to send it as <i>application/x-www-form-urlencoded</i>
  by changing the <i><tt class="parameter">method</tt></i>
 attribute to
  <em class="emphasis">urlencoded-post</em>.
 </p>
 <div class="example">
  <p><b>Example #2 Using an XForm to populate <var class="varname"><a href="reserved.variables.post.php" class="classname">$_POST</a></var></b></p>
  <div class="example-contents programlisting">
<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><p><b class="note">Note</b>:
  <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>
<?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites