EasyHttpRequests

Summary: Quickly and easily retrieve variables from a URL (HTTP Requests)
Version: 1.0
Prerequisites:
Status: Insecure
Maintainer: overtones99
Categories: Markup

Questions answered by this recipe

How can I pass and retrieve a page variable in pmwiki via a URL?

Description

A simple way to pass and retrieve page variables via a URL (HTTP Requests).

Sending & Requesting Variables via HTTP Requests
1. Paste the following (or something similar) in your config.php:

      //// GET VARIABLES FROM URL ////
      $FmtPV['$urlVarX'] = $_REQUEST['x'];
      $FmtPV['$urlVarY'] = $_REQUEST['y'];
      $FmtPV['$urlVarZ'] = $_REQUEST['z'];

      # This method is critically insecure, it allows PHP code injection
see: PageVariables and recipe Cookbook:HttpVariables for a better way. Siegfried Seibert (2015-12-19)

2. Then, if you'd like to pass a variable to a page, you can add it to your URL as such:

send one variable:
http://myPmwikiSite.com/pmwiki/MyGroup/MyPage?x=blam
or send multiple variables by separating them with an ampersand (&):
http://myPmwikiSite.com/pmwiki/MyGroup/MyPage?x=blam&y=blee&z=blech


3. Finally, request the variable(s) by calling the PageVariables {$urlVarX}, {$urlVarY}, {$urlVarZ} on your PmWiki page.

By clicking this link to this current page (notice the appended variables), the variables would show up below:
http://www.pmwiki.org/wiki/Cookbook/EasyHttpRequests#example?x=blam&y=blee&z=blech
(note: this is not currently implemented on this page)

current x-var: {$urlVarX}
current y-var: {$urlVarY}
current z-var: {$urlVarZ}

this should then show up on your page:

current x-var: blam
current y-var: blee
current z-var: blech

Notes

Release Notes

  • Added 2008-06-28

See Also

SearchQueryVariable - very similar, in fact basically the same, but geared towards requesting search variables...
HttpVariables - A slightly more generic recipe to do things like (+ post, cookies and session variables)
Request - Allows conditional tests for whether a variable is in the Url, and what its value is

Contributors

overtones99

Comments

See discussion at EasyHttpRequests-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.