Jump to content

Changing some fields


BigBobby

Recommended Posts

OK, I have jsut downlaoded a Instant Messenger script which I will hopefully integrate in to my site but I have ran in to a few problems, could anyone possiblely help:

 

So far I have the made it so the registration works and it adds to the right table which is the users.

 

Orginal Code:

 

   case 'login':
      ///////////// login to the server /////////
      // login parts (within array $_POST):    //
      // from     -  user logging in           //
      // pwd      -  password                  //
      ///////////////////////////////////////////
      $query = @mysql_query("SELECT buddylist FROM ".SQL_PREFIX."users WHERE username='".mysql_real_escape_string($from)."' AND password='".$pwd."'");
      if(@mysql_num_rows($query) > 0) {
         $user = mysql_fetch_assoc($query);
         $set_status = @mysql_query("UPDATE ".SQL_PREFIX."users SET is_online='1' WHERE username='".mysql_real_escape_string($from)."'");
         if(strlen($user['buddylist']) > 0) {
            $buddylist = user_event($from, $user['buddylist'], 'status,1');
            $output['buddy'] = $json->encode($buddylist);
         } else {
            $output['buddy'] = Array();
         }
         
         print($json->encode($output));
      } else {
         print 'invalid';
      }
      break;

 

An here is my atempt at changing username and password to alias and pass.

 

I have added all the correct fields to my table.

 

   case 'login':
      ///////////// login to the server /////////
      // login parts (within array $_POST):    //
      // from     -  user logging in           //
      // pwd      -  password                  //
      ///////////////////////////////////////////
      $query = @mysql_query("SELECT buddylist FROM users WHERE alias='".mysql_real_escape_string($from)."' AND pass='".$pwd."'");
      if(@mysql_num_rows($query) > 0) {
         $user = mysql_fetch_assoc($query);
         $set_status = @mysql_query("UPDATE users SET is_online='1' WHERE alias='".mysql_real_escape_string($from)."'");
         if(strlen($user['buddylist']) > 0) {
            $buddylist = user_event($from, $user['buddylist'], 'status,1');
            $output['buddy'] = $json->encode($buddylist);
         } else {
            $output['buddy'] = Array();
         }
         
         print($json->encode($output));
      } else {
         print 'invalid';
      }
      break;

 

Can any one notice anyhting?

Link to comment
https://forums.phpfreaks.com/topic/60795-changing-some-fields/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.