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.
true
– (standard) display warning (warning is only visible to the project administrator, not the participant)false
– hide warning: the project administrator knows what he is doing
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.
option('resume', true)
, or if the project administrator ensures the variable was transmitted by using an appropriate link.readGET()
, check whether a value has already been set. In the examples below, isset()
or getRoute()
is used to do so. For example, if you put a compulsory question on the first page in the questionnaire, the first page will be shown again if no answer is given, but readGET()
is unable to read the value anymore. This “no value” would then overwrite the correct value already stored.
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); }
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); }