diff --git a/interface/lib/classes/auth.inc.php b/interface/lib/classes/auth.inc.php
index 450f25a3ca8f1095b3a4ac2060671cc0b45a6bb9..1002bd6949f8d5515ff161f8b75d36ddc93cf6bf 100644
--- a/interface/lib/classes/auth.inc.php
+++ b/interface/lib/classes/auth.inc.php
@@ -123,6 +123,15 @@ class auth {
 			exit;
 		}
 	}
+	
+	public function get_random_password($length = 8) {
+		$base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+		$password = '';
+		for ($n=0;$n<$length;$n++) {
+			$password.=$base64_alphabet[mt_rand(0,63)];
+		}
+		return $password;
+	}
 		
 }
 
diff --git a/interface/lib/classes/tform.inc.php b/interface/lib/classes/tform.inc.php
index e43eae94ffee18540b717b1549b2dbf4a0e94734..3ca2c06d4d003d83bee160eb9040fcc56aea5884 100644
--- a/interface/lib/classes/tform.inc.php
+++ b/interface/lib/classes/tform.inc.php
@@ -166,6 +166,9 @@ class tform {
                 global $conf, $app;
 				if(!is_array($this->formDef['tabs'][$tab])) $app->error("Tab does not exist or the tab is empty (TAB: $tab).");
                 $new_record = '';
+				$table_idx = $this->formDef['db_table_idx'];
+				if(isset($record[$table_idx])) $new_record[$table_idx] = intval($record[$table_idx ]);
+				
 				if(is_array($record)) {
                         foreach($this->formDef['tabs'][$tab]['fields'] as $key => $field) {
                                 switch ($field['datatype']) {
@@ -236,11 +239,12 @@ class tform {
                         $table_idx = $this->formDef['db_table_idx'];
 						
 						$tmp_recordid = (isset($record[$table_idx]))?$record[$table_idx]:0;
+						//$tmp_recordid = intval($this->primary_id);
                         $querystring = str_replace("{RECORDID}",$tmp_recordid,$querystring);
 						unset($tmp_recordid);
 						
                         $querystring = str_replace("{AUTHSQL}",$this->getAuthSQL('r'),$querystring);
-
+						
                         // Getting the records
                         $tmp_records = $app->db->queryAllRecords($querystring);
                         if($app->db->errorMessage != '') die($app->db->errorMessage);