Community Support for OpenDocMan (Deprecated)

Full Version: How do I add a line to history on authorize?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to add what sounds like a very simple feature, but am having some issues with PHP. I can read and somewhat understand the PHP, but am more comfortable with VB and Java. What I'm trying to add looks like it should be no more than 2 lines of code, but I cannot get those to work.

I am trying to get it to record in history when someone authorizes a document. I took the code that is added when someone adds a document from add.php. Here is the code that looks like it is making the history comment:// Add a log entry
$query = "INSERT INTO log (id,modified_on, modified_by, note, revision) VALUES ( '$fileId', NOW(), '" . addslashes($username) . "', 'Initial import', 'current')";
$result = mysql_query($query, $GLOBALS['connection']) or die ("Error in query: $query. " . mysql_error());

When I add this to toBePublished.php I get errors. If any one could help me out I would appreciate it.

Thank you.
dvst8s
In case anyone else is wanting to do this the code below is what worked for me. You would just insert it above the } above the header('Location:' . $_SERVER['PHP_SELF'] .....line at the bottom of tobepublished.php.

//Find out the owners' username to add to log
$query = "SELECT username from user where id='$_SESSION[uid]'";
$result = mysql_query($query, $GLOBALS['connection']) or die ("Error in query: $query. " . mysql_error());
list($username) = mysql_fetch_row($result);

// Add a log entry for authorizing
$query = "INSERT INTO log (id,modified_on, modified_by, note, revision) VALUES ( '$fileid', NOW(), '" . addslashes($username) . "', 'Authorized', 'current')";
$result = mysql_query($query, $GLOBALS['connection']) or die ("Error in query: $query. " . mysql_error());
//End Added to try and log when someone Authorizes a document

dvst8s