// enhanced if ($prevmessageid) {
$the_pm_id = $DB_site->insert_id();
if ($touserinfo[emailonpm]) {
$DB_site->query("UPDATE privatemessage SET messageread=1, readtime='".time()."', receipt=2 WHERE privatemessageid=$the_pm_id");