title: PHP MySQL Triggers - How to pass variables to trigger?
body: <p>I'm trying to find how to send variables in a query to the trigger, but it's going to affect a second table. I'm using this to create a log table, in which anything that gets updated or inserted gets recorded in the log table For example</p>
  
  <pre><code>//Inserts into the table the username and password
  $sql = "INSERT INTO table VALUES ($_POST['username'], $_SESSION['password']);
  </code></pre>
  
  <p>Trigger DDL Statements</p>
  
  <pre><code>DELIMITER $$
  
  //Creates trigger to insert into table1 ( logs ) the userid and patientid ( which has to come from php )
  USE `baemer_emr`$$
  
  CREATE
  DEFINER=`baemer_emr`@`localhost`
  TRIGGER `table1`.`after_insert`
  AFTER INSERT ON `baemer_emr`.`table1`
  FOR EACH ROW
  BEGIN
    INSERT INTO table2 VALUES (NEW.idn, $_POST[userid], $_SESSION[patientid]);
  END$$
  </code></pre>
  
  <p>Is this possible?</p>