This topic is locked

passing id to another add form

12/13/2007 2:06:47 PM
PHPRunner General questions
D
dakk author

I have a add form that when saved it commits a record to table1 and produces an ID key. I want to pass this ID key to the table2 form that opens automatically with an event I have on table 1 add form.
I have searched the forum and this issue is danced around but I seam not to be able to find the magical answer. phprunner4.1 oracle 10G

G
garethpDevClub member 12/14/2007

I am by no means an expert but this may help as I had the same problem. You may get a better answer from someone else!
I have an after record added event with the following code - i redirect to the list page but this works with directing to an add page also:

//** Custom code ****

// put your custom code here
$_SESSION["details_mastertable"]="requisition";

$_SESSION["details_masterkey1"]=$keys["requisition"];
header("Location: details_list.php?mastertable=requisition&masterkey1=".$keys["requisition"]);

exit();


Table 1 is called requisition and Table 2 is called details. The ID field is also called requisition in my example- sorry!

D
dakk author 12/18/2007

Thanks garethp for the reply but I couldn't get your suggestion to work.
Table1 is writing an ID primary key called CG22PKGSTOR_ID
This is my AfterAdd event code on my first add page which writes to table1:
function AfterAdd(&$values,&$keys,$inline)

{

$_SESSION["CG22PKGSTOR_ID"]=$keys["CG22PKGSTOR_ID"];

header("Location: ARCHIVE_DOC_STOR_DOC_NAME_add.php");

exit();

}
On the ARCHIVE_DOC_STOR_DOC_NAME_add.php page I have a text field with "Edit as" setting Default Value: is $_SESSION["CG22PKGSTOR_ID"]
The CG22PKGSTOR_ID isn't showing any value in the add page field and hence not writing to the second table when submitting. I don't see where I'm in error. Please HELP.
NOTE: I can pass a value via the session variable if I hard code a literal value.