codice:
if ((eregi ('^[0-9]{7}[1-8]{1}$', $code)) AND ((int)$code{0}+(int)$code{7}==9)){
    $query = "SELECT * FROM {$tabella} WHERE codice = '{$code}'"; 
    $result = mysql_query( $query ) or die ("status=Errore nella query!"); 
    if (mysql_num_rows($result)) { 
		echo "status=CODICE corretto ma utilizzato&checklog=3";
	}
	else {
		$queryins = "UPDATE {$tabella} SET codice ='{$code}' WHERE data=CURDATE(); ";
		mysql_query( $queryins ) or die ("status=Errore nella query!");
		echo "status=CODICE ESATTO-dati inseriti&checklog=1";
	}
}
else {
	echo "status=CODICE ERRATO&checklog=2";
}

ah io metterei

$code = (string)$_POST['code'];