This topic is locked

problem with custom code

4/14/2008 2:02:25 PM
PHPRunner General questions
E
ellesse author

Hello,

this is my problem:

I have a customer table, with custom code on after record added that redirect to the customer list.

Also I have a invoice table with a field customer ID. If I use add new function to add a new customer, when I save the new customer, appear a table list of customers, and don't return to field customer ID

How I resolve?
Thank You
Leonardo Santoro

J
Jane 4/15/2008

Leonardo,
to redirect to teh view page after adding new record use this code in the After record added event:

header("Location: TableName_view.php?editid1=".$keys["RecordID"]);

exit();



where RecordID is your actual field name, TableName is your actual table name.

E
ellesse author 4/16/2008

Ok.

But if I use now in Allow to add new values on the fly doesn't work correctly, because when I add a new customer on the fly do not return properly.

J
Jane 4/17/2008

Hi,
you can do the following:

  1. check type of add page (simple or "add on the fly") in the Add page: Before process event:
    if ($_GET["editType"]!="onthefly")

    $_SESSION["onthefly"] = 1;


2. redirect to the view page for simple add page only:

if (!$_SESSION["onthefly"])

{

header("Location: TableName_view.php?editid1=".$keys["RecordID"]);

exit();

$_SESSION["onthefly"] = 0;

}