This topic is locked

Save data before process them with a snippet

6/23/2011 2:11:28 PM
PHPRunner General questions
J
JCRamos author

In my page "TABLE_ADD" I have a snippet with a link that calls an external PHP page that processes the data recorded in this row of the table.



if (($_SESSION["w_validado"]!="S") and ($_SESSION["w_validador"]=='S'))

{ $parametros="?id=".$_REQUEST["editid1"]."&validador=".$_SESSION["UserID"]."&validado=S";

echo "<a href='validar_prueba.php".$parametros."' title='Validar la prueba'>[VALIDAR]</a>";

echo " ";

}



I would like this snippet before calling the page, record data, that is, as if the user presses the button "SAVE".

How I can do?

C
cgphp 6/23/2011

I'm not sure I understand what you mean.
Check this: http://xlinesoft.com/phprunner/docs/after_record_added.htm

J
JCRamos author 6/23/2011

I want to programmatically simulate pressing the SAVE button in an add or edit page.
Thanks.

C
cgphp 6/23/2011

There is a simpler solution.

  1. Initialize the validar_prueba.php file (you could use require function) in the AfterAppInit event so every functions inside it is available to the entire application
  2. In the BeforeAdd event of TABLE_ADD, process the data, you want to save, calling a validation function from validar_prueba.php
  3. Return false if the validation failed, true otherwise
    Check these pages as reference:
    http://xlinesoft.com/phprunner/docs/after_application_initialized.htm

    http://xlinesoft.com/phprunner/docs/before_record_added.htm

J
JCRamos author 6/23/2011

Thanks for the help, but I do not need to change the way the program validates the data.

What I need is that data is always recorded in the database before doing the validation.

Therefore, there must be a way to programmatically execute the same actions as does the button "SAVE" to prevent the user forgets click it.
Thank you.

C
cgphp 6/23/2011

Ok! The prueba is a sort of exam.
The second answer in this thread is the solution. Put this code:



if (($_SESSION["w_validado"]!="S") and ($_SESSION["w_validador"]=='S'))

{

$parametros="?id=".$values['insert_here_the_field_name']."&validador=".$_SESSION["UserID"]."&validado=S";

header("Location: validar_prueba.php".$parametros);

exit();

}


in the After Record Added event.
Hope this help.