insert value from login table

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
droogers
User
Posts: 72

insert value from login table

Post by droogers »

Hello,

In my login table I have a field with the name "soort_lid".
In the project I have the table tblconferentie_opgeven. When I add a record to this table I want to automatically insert the value of the login table "soort_lid". How do I do this ?


mobhar
User
Posts: 11703

Post by mobhar »

You may simply use:

CurrentUserInfo("soort_lid")


droogers
User
Posts: 72

Post by droogers »

I filled in this code but it didn't work:
// Recordset Selecting event
function Recordset_Selecting(&$filter) {
$lid = CurrentUserInfo("Soort_lid");
}


mobhar
User
Posts: 11703

Post by mobhar »

Your code is wrong. Please read "Server Events and Client Scripts" topic from PHPMaker Help menu for more info and example.


Webmaster
User
Posts: 9427

Post by Webmaster »

droogers wrote:
When I add a record to this table I want to automatically insert the value of the login table "soort_lid". How do I do this ?

Use Row_Inserting server event, see Server Events and Client Scripts in the help file.


droogers
User
Posts: 72

Post by droogers »

I now tried this code but it also didn't work:

function Row_Inserting($rsold, &$rsnew) {
// Enter your code here
// To cancel, set return value to FALSE
if($rsnew["lid"]="")
$rsnew["lid"]=CurrentUserInfo("soort_lid");
// return TRUE;
}


sangnandar
User
Posts: 980

Post by sangnandar »

function Row_Inserting($rsold, &$rsnew) {
if($rsnew["lid"]="") // Careful with this. If this is auto increment primary key then $rsnew["lid"] is not yet available in Row_Inserting() event.
$rsnew["soort_lid"] = "your value";
}

OR

function Row_Inserted($rsold, &$rsnew) {
if($rsnew["lid"]="")
ew_Execute("insert into yourtable(...) values(...) where lid=".$rsnew["lid"]); //use quote if $rsnew["lid"] is not INT datatype.
}


mobhar
User
Posts: 11703

Post by mobhar »

Your code should be like this for that event:

function Row_Inserting($rsold, &$rsnew) {
// Enter your code here
// To cancel, set return value to FALSE

if ($rsnew["lid"] == "")
$rsnew["lid"] = CurrentUserInfo("soort_lid");

return TRUE; // <-- make sure you did not remove this part

}


Post Reply