function SetLogin(&$smarty, $form = false, $pageredir = "index")
 {
     $ck = new Check('POST');
     $mysql = new MYSQL($smarty);
     if ($ck->form['cookieleng'] == $smarty->get_config_vars('Login00')) {
         $cookielength = 0;
         $cookieneverexp = 'on';
     } else {
         $cookielength = $ck->form['cookieleng'];
     }
     $user = $ck->form['login_user'];
     $pass = $ck->form['login_password'];
     $request = $mysql->SqlSelect("SELECT * FROM {$smarty->cfg[prefix]}members WHERE member_name='{$user}'", __FILE__, __LINE__);
     $perfil = mysql_fetch_array($request, MYSQL_ASSOC);
     $md5_passwrd = $this->md5_hmac($pass, strtolower($user));
     switch ($cookielength) {
         case "1":
             $cookielength = strtotime("+30 minutes");
             break;
         case "2":
             $cookielength = strtotime("+1 hour");
             break;
         case "3":
             $cookielength = strtotime("+1 day");
             break;
         case "4":
             $cookielength = strtotime("+1 month");
             break;
         case "5":
             $cookielength = strtotime("+1 year");
             break;
         default:
             $cookielength = strtotime("+1 year");
     }
     $password = $this->md5_hmac($md5_passwrd, 'ys');
     $cookie_url = explode($smarty->cfg["separate"], $this->url_parts($smarty->get_config_vars('http'), $smarty->cfg["separate"]));
     $cookie = serialize(array($perfil['ID_MEMBER'], $password));
     $ctime = $cookielength;
     //print $smarty->cfg['cookie'].' , ' .$cookie.' , '. $ctime.' , '. $cookie_url[1].' , '. $cookie_url[0];
     setcookie($smarty->cfg['cookie'], $cookie, $ctime, $cookie_url[1], $cookie_url[0]);
     $lastLog = time();
     $memIP = $_SERVER[REMOTE_ADDR];
     $valores = array('member_lastlogin' => $lastLog, 'member_ip' => $memIP);
     $sql = $mysql->SqlUpdate($smarty->cfg["prefix"] . 'members', $valores, "member_name='{$user}'");
     $result = $mysql->SqlSelect($sql);
     $identify = INET_ATON();
     $sql = $mysql->SqlDelete($smarty->cfg["prefix"] . 'log_online', "identity='{$identify}'");
     $result = $mysql->SqlSelect($sql);
     $redir = $smarty->get_config_vars('http') . $smarty->cfg['index'] . '?page=' . $pageredir;
     header("location:{$redir}");
 }
<?php

$tabela = 'produtos';
$mysql = new MYSQL($cfg);
$idde = trim($_POST['id']);
if (trim($_POST['edit'])) {
    array_pop($_POST);
    $sql = $mysql->SqlUpdate($tabela, $_POST, "id = '{$idde}'");
    $request = $mysql->SqlSelect($sql);
    $request = $mysql->SqlSelect($sql, __FILE__, __LINE__);
    if (request) {
        print "<h4>Registro Atualizado com sucesso!!!</h4>";
    }
}
$result = $mysql->SqlSelect("SELECT * FROM {$tabela} WHERE id = '" . $idde . "'");
$item = mysql_fetch_array($result, MYSQL_ASSOC);
?>

<form action="index.php?p=produtos&a=edit" method="post">
<label for="nome">Nome:<br />
    <input name="nome" type="text" value="<?php 
echo $item['nome'];
?>
" />
</label><br />
<label for="descricao">Descrição:<br />
<textarea name="descricao"><?php 
echo $item['descricao'];
?>
</textarea>
</label><br />
 public function logMe($ID_MEMBER, $min = '15')
 {
     $mysql = new MYSQL($this);
     $tabela = $this->cfg['db_prefix'] . 'log_online';
     $logme['identity'] = $ID_MEMBER;
     $perfil['member_lastlogin'] = $logme['logTime'] = 'NOW()';
     $perfil['member_lestonline'] = $logme['logoutTime'] = "NOW() + INTERVAL " . $min . " MINUTE";
     $logme['url'] = $this->actualpage['page_name'] ? $this->actualpage['page_name'] : "index";
     $logme['ip'] = $_SERVER['REMOTE_ADDR'];
     $request = $mysql->SqlSelect("Select identity From {$tabela} where ip = \"{$logme[ip]}\" and identity = \"{$ID_MEMBER}\"", __FILE__, __LINE__);
     mysql_affected_rows();
     if (mysql_affected_rows() > 0) {
         $sql = $mysql->SqlUpdate($tabela, $logme, "identity = {$ID_MEMBER}");
     } else {
         $sql = $mysql->SqlInsert($tabela, $logme);
     }
     $request = $mysql->SqlSelect($sql, __FILE__, __LINE__);
     $tabela = $this->cfg['db_prefix'] . 'log_online';
     $sql = $mysql->SqlUpdate($tabela, $logme, "identity =" . $ID_MEMBER);
     $request = $mysql->SqlSelect($sql, __FILE__, __LINE__);
     $sql = $mysql->SqlDelete($tabela, "logoutTime < NOW()");
     $request = $mysql->SqlSelect($sql, __FILE__, __LINE__);
     if ($ID_MEMBER > 0) {
         $tabela = $this->cfg['db_prefix'] . 'members';
         $sql = $mysql->SqlUpdate($tabela, $perfil, "ID_MEMBER =" . $ID_MEMBER);
         $request = $mysql->SqlSelect($sql, __FILE__, __LINE__);
     }
 }