Inhaltsverzeichnis

readGET()

string|false readGET(string ID, [boolean warning])

The function readGET() allows a variable to be read that was transmitted to the questionnaire via POST or GET.

The function's return value is the string that was transmitted using POST or GET when the questionnaire is called up. If the variable was not transmitted, false will be returned.

Notes

Example 1

For example, the variable panelID was transmitted with the value “12345” (e.g. https://www.soscisurvey.de/demo/?panelID=12345) and so the value “12345” can be determined with readGET('panelID').

The use of isset() ensures that the value read will not be overwritten if the page is shown again later (.e.g. after pressing the back button or if the page is repeated again as answers are missing).

if (!isset($id)) {
  $id = readGET('panelID');
  // register variable for later use
  registerVariable($id);
}

Example 2

In the following code example, two variables (tic and pid) are read on the first page of the questionnaire and saved as internal variables. The internal variables IV01_01 and IV01_02 have to be created beforehand in the List of Questions.

In addition, the ID for pid is set up as the placeholder %pid% in order for it to be used later in a redirect link (e.g. https://www.panelanbieter.com/redirect.php?user=%pid%).

Here, the use of getRoute() ensures that reading and, crucially, put is implemented at the start of the questionnaire only.

if (getRoute() == 'start') {
  $tic = readGET('tic');
  put('IV01_01', $tic);
  $pid = readGET('pid');
  put('IV01_02', $pid);
  // set up pid in addition as placeholder to redirect
  replace('%pid%', $pid);
}