This topic is locked

Insert a record into another table

11/20/2007 3:41:28 PM
PHPRunner General questions
G
gbhmayer author

I have two tables: access (access controls): access_id/user_id/date_hour
and user(users logins):user_id/login/full_name.....
In the event after successful login i would like to insert the actual record (loggin user_id from user) into user_id from access.

J
Jane 11/21/2007

Gerson,
try to use this code:

global $conn;

$str = "select user_id from user where login='".$_SESSION["UserID"]."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);
$strInsert = "insert into access (user_id,date_hour) values (".$data["user_id"].",now())";

db_exec($strInsert,$conn);