This topic is locked
[SOLVED]

 Call PHPRunner generated page with parameters from outside

6/10/2017 5:25:01 AM
PHPRunner General questions
J
JCRamos author

I want to use a single application generated by PHPRunner so that the records displayed in a table depend on the parameters that the project start page receives.

Example:

This common application contains the "" condition.

To call the application I created a previous page named "[font="Courier New"]index.php" .

This page starts a session with " the parameters passed in the URL:
[font="Courier New"]index.php?desde=2&hasta=3

<?php

// Enable sessions

session_start();

$_SESSION['grupo_desde'] = $_GET['desde'];

$_SESSION['grupo_hasta'] = $_GET['hasta'];

// Go to List Page

header("Location: output/documentos_list.php");

?>



Inside event I modify the table's where clause:

$desde=$_SESSION['grupo_desde'];

$hasta=$_SESSION['grupo_hasta'];

$query->addWhere(" grupo between '".$desde."' and '".$hasta."' ");



This does not work, since when arriving at the code of this event the initial session no longer exists, but only the initiated in [font="Courier New"]dbcommon.php.

Any idea how to pass parameters from outside of a PHPRunner generated page and that another one inside pick them up and use them?

Thank you.

J
JCRamos author 6/10/2017

The solution is to use .
Our URL would be:[font="Courier New"] index.php?desde=2&hasta=3
The file would be:

<?php

// Utilizamos cookies para pasar al proyecto valores que puedan usarse dentro de él:

if(!isset($_COOKIE['grupo_desde']))

setcookie('grupo_desde',$_GET['desde'],time() + 10);

else

setcookie('grupo_desde','',time() + 10);

if(!isset($_COOKIE['grupo_hasta']))

setcookie('grupo_hasta',$_GET['hasta'],time() + 10);

else

setcookie('grupo_hasta','',time() + 10);

// Ir a la pagina inicial

header("Location: documentos_list.php");

?>


The [font="Courier New"]documentos.AfterTableInitialized event:

// Solo veremos de la tabla aquellos grupos que se indicaron como parametros en la pagina de llamada al proyecto :

if(!isset($_COOKIE['grupo_desde']))

{ $desde=$_SESSION['grupo_desde'];

}

else

{ $desde=$_COOKIE['grupo_desde'];

$_SESSION['grupo_desde']=$desde;

setcookie('grupo_desde', '', time() - 10);

}

if(!isset($_COOKIE['grupo_hasta']))

{ $hasta=$_SESSION['grupo_hasta'];

}

else

{ $hasta=$_COOKIE['grupo_hasta'];

$_SESSION['grupo_hasta']=$hasta;

setcookie('grupo_hasta', '', time() - 10);

}

// Añadimos la condicion

$query->addWhere(" grupo between '".$desde."' and '".$hasta."' ");