Submit html Form to an embedded php Script

Hello,

is it somehow possible to submit a html Form to an embedded php Script?

For example I have this html form:

{{html}}
 
  <form action="" id="test" method="post">
    <div>
      test1: <input type="text" name="test1" value="Enter your question here" class="withTip" size="100"/><br>
	  test2: <input type="text" name="test2" value="Enter your question here" class="withTip" size="100"/><br>
      <span class="buttonwrapper"><input type="submit" value="Create Test" class="button"/></span>
    </div>
  </form>
{{/html}}

And I would like to have a php Script executed after sending the Submit button, I also need to access the form elements inside the php Script.

Thanks in advance!
Best Regards
Manuel

{{python}}
if not request.get("test1") is None:
  print "test1 Question:", request.get("test1")
{{/python}}

Hello!

This seems to work, but it is only possible to access the Get / Post Data via Python?

I’ve tried that with PHP, but nothing useful is displayed:

{{php}}
<?php 
   print_r($_POST); 
   print_r($_GET);
   print_r(file_get_contents('php://input'));
?>
{{/php}}

Sorry switched to wrong language …

{{php}}
<?php
   if ($request->get("test1") != NULL) { echo "\nParameter test1: ",   $request->get("test1") };
   if ($request->get("test2") != NULL) { echo "\nParameter test2: ",   $request->get("test2") };
  
  // if a parameter is given multiple you can get an array
  
    if ($request->get("test1") != NULL)  { echo "\nParameter test1: ",  $request->getParameterValues("test1")[0] };
    if ($request->get("test2") != NULL)  { echo "\nParameter test2: ",  $request->getParameterValues("test2")[0] };

  // other stuff
  
    echo "\nRemote Addr: ",      $request->getRemoteAddr();
    echo "\nRemote host: ",      $request->getRemoteHost();
?>
{{/php}}

An additional notice:

XWiki allows several script languages, e.g. {{velocity}} {{groovy}} {{php}} {{python}}

You can used different languages in the same document and they SHARE THE NAMESPACE (binding) !

e.g. A variable set in {{velocity}} may be used later in {{groovy}} with its values.

e.g The $request function is one many XWiki standard objects with a set of an additional methods.