14, February 2012

updateUser funtion - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  Php User Class
Topic: updateUser funtion
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: updateUser funtion  (Read 2036 times)
Google dot what?
*
Posts: 2
16 credits
Members referred : 0


« on: Oct 17, 2008, 08:51:22 pm »

I've made a function to update the user data.

Code:
<?php
  
/*
   * Updates an user account. The array should have the form 'database field' => 'value'
   * @param array $data
   * return int
   */
  function updateUser($data) {
    if (!is_array($data)) $this->error('Data is not an array'__LINE__);
    $setpart "";
    foreach ($data as $k => $v) {
      if ($k != 'pass') {
        $setpart .= "`$k` = '".$this->escape($v)."', ";
      } else {
        switch(strtolower($this->passMethod)) {
          case 'sha1':
            $password "SHA1('".$data[$this->tbFields['pass']]."')"; break;
          case 'md5':
            $password "MD5('".$data[$this->tbFields['pass']]."')"; break;
          case 'nothing':
            $password $data[$this->tbFields['pass']];
          }
        $setpart .= "`$k` = $password, ";
        }
      }
    $setpart substr($setpart0, -2);
    return ($this->query("UPDATE `{$this->dbTable}` SET $setpart WHERE `{$this->tbFields['userID']}` = '".$this->escape($this->userID)."' LIMIT 1"));
  }
?>

« Last Edit: Oct 17, 2008, 10:46:27 pm by lordt »
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5779
46271 credits
Members referred : 3



« Reply #1 on: Oct 17, 2008, 11:29:48 pm »

Thanks for your contribution lordt and welcome to webdigity Smiley

In the next version I will combine your code with another user contribution

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
OMG!I am geek
**
Gender: Male
Posts: 50
312 credits
Members referred : 0

in a world of php


« Reply #2 on: Oct 18, 2008, 08:45:58 am »

looks close to the same as the updateProperty function posted here , does it do anything different or just a cleaner code?
Google dot what?
*
Posts: 2
16 credits
Members referred : 0


« Reply #3 on: Oct 19, 2008, 10:37:10 pm »

looks close to the same as the updateProperty function posted here , does it do anything different or just a cleaner code?
I just did it before to discover the other function. I don't know which of them is better. Cheesy
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=8100
Tags : php updateUser Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  Php User Class
Topic: updateUser funtion
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Feb 14, 2012, 04:56:57 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.