"remember me" login checkbox

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   "remember me" login checkbox
zhenghe
CZ Newbie
zhenghe has been a member for over 19 year's 19 Year Member
Gender: Male
Status: Offline
Joined: Oct 26, 2005
0.00 posts per day
Posts: 4
Points: 166
   
Hello

I'm trying to modify the "Your_Account" module, in order to append a check box for remember the user. Something like the block here, but without a combo. The problem is that i modified the functions in the file (see code below) but i cannot make it work. I think the problem has to do with global vars. I define a new global var, but idon't know if i'm doing it right, or getting the original values right. Well, here's the code

function main
function main($user) {
    global $stop, $module_name, $redirect, $mode, $t, $f;
   global $user_remember;
    if(!is_user($user)) {
   include("header.php");
   echo "<img border=\"0\" src=\"themes/Nuke_Octopus/images/barralogin.jpg\">";
   if (!is_user($user)) {
       OpenTable();
       mt_srand ((double)microtime()*1000000);
       $maxran = 1000000;
       $random_num = mt_rand(0, $maxran);
       echo "<br><form action=\"modules.php?name=$module_name\" method=\"post\">\n"
      ."<b>"._USERLOGIN."</b><br><br>\n"
      ."<table border=\"0\"><tr><td>\n"
      .""._NICKNAME.":</td><td><input type=\"text\" name=\"username\" size=\"15\" maxlength=\"25\"></td></tr>\n"
      ."<tr><td>"._PASSWORD.":</td><td><input type=\"password\" name=\"user_password\" size=\"15\" maxlength=\"20\"></td></tr>\n";
       if (extension_loaded("gd")) {
      echo "<tr><td colspan='2'>"._SECURITYCODE.": <img src='modules.php?name=$module_name&op=gfx&random_num=$random_num' border='1' alt='"._SECURITYCODE."' title='"._SECURITYCODE."'></td></tr>\n"
          ."<tr><td colspan='2'>"._TYPESECCODE.": <input type=\"text\" NAME=\"gfx_check\" SIZE=\"7\" MAXLENGTH=\"6\"></td></tr>\n"
          ."<input type=\"hidden\" name=\"random_num\" value=\"$random_num\">\n";
       }
      echo "<tr><td>¿Recordarte en este equipo?:</td><td><input type=\"checkbox\" name=\"user_remember\" value =\"0\"></td></tr>\n";
      echo "<tr><td colspan=\"2\">(No lo selecciones si est&aacute;s en un terminal p&uacute;blico)</td></tr>\n";

       echo "</table><input type=\"hidden\" name=\"redirect\" value=$redirect>\n"
      ."<input type=\"hidden\" name=\"mode\" value=$mode>\n"
      ."<input type=\"hidden\" name=\"f\" value=$f>\n"
      ."<input type=\"hidden\" name=\"t\" value=$t>\n"
      ."<input type=\"hidden\" name=\"op\" value=\"login\">\n"
      ."<input type=\"submit\" value=\""._LOGIN."\"></form><br>\n\n"
      ."<center><font class=\"content\">[ <a href=\"modules.php?name=$module_name&amp;op=pass_lost\">"._PASSWORDLOST."</a> | <a href=\"modules.php?name=$module_name&amp;op=new_user\">"._REGNEWUSER."</a> ]</font></center><br>\n";
       CloseTable();
   }
   include("footer.php");
    } elseif (is_user($user)) {
        global $cookie;
        cookiedecode($user);
        userinfo($cookie[1]);
    }
}


function docookie
function docookie($setuid, $setusername, $setpass, $setstorynum, $setumode, $setuorder, $setthold, $setnoscore, $setublockon, $settheme, $setcommentmax) {
    global $user_remember;

   if ( ($setusername == '') || !preg_match('/^[a-zA-Z0-9_-]+$/', $setusername) ) die('Mensaje de la sala: nombre de usuario ilegal');
   if ( ($setpass == '') || !preg_match('/^[a-fA-F0-9]{32}$/', $setpass) ) die('Mensaje de la sala: password ilegal');
 
    $info = base64_encode("$setuid:$setusername:$setpass:$setstorynum:$setumode:$setuorder:$setthold:$setnoscore:$setublockon:$settheme:$setcommentmax");
   if ( !isset($user_remember) || (intval($user_remember) != 1) )
   {
     setcookie("user","$info");
   }
    else
   {
     setcookie("user","$info",time()+2592000);   //60*60*24*30 = 30 days
   }
//    setcookie("user","$info",time()+2592000);
}


So, this is it... how can i do it?
Thanks in advance

Zhenghe


Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum