11, October 2008

get_user_info and non protected pages - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: get_user_info and non protected pages
« previous next »
Pages: [1] Print

Author Topic: get_user_info and non protected pages  (Read 1018 times)
What a dork
*
Posts: 15
106 credits
Members referred : 0


« on: Dec 29, 2006, 02:18:47 PM »

Hi Olaf,

I ran into a small problem when trying to use the get_user_info() function on a page that's not protected.  Since this function is only valid on pages which are protected (i.e. access_page() called prior to get_user_info()), if you want to get the user info for non protected pages, it returns nothing.

Therefore, in your class I added a method called get_nonprotected_user_info() which is very similar to the get_user_info().  You can see it below:

function get_nonprotected_user_info() {
     if (isset($_SESSION['user']) && isset($_SESSION['pw'])) {
        $this->user = $_SESSION['user'];
        $this->user_pw = $_SESSION['pw'];
     }
     //$sql_info = sprintf("SELECT real_name, extra_info, email, id FROM %s WHERE login = '%s' AND pw = '%s'", $this->table_name, $this->user, $this->user_pw);
     $sql_info = sprintf("SELECT real_name, extra_info, email, id FROM %s WHERE %s = '%s' AND pw = '%s'", $this->table_name, $this->logtyp, $this->user, $this->user_pw);
     $res_info = mysql_query($sql_info);
     $this->id = mysql_result($res_info, 0, "id");
     $this->user_full_name = mysql_result($res_info, 0, "real_name");
     $this->user_info = mysql_result($res_info, 0, "extra_info");
     $this->user_email = mysql_result($res_info, 0, "email");
   }

Basically I just added a check to see if the user is valid.  This way I can call get_nonprocted_user_info() on any page that doesn't need to be protected.  Works good, but wanted to hear your comments as I might be using the class wrong.

Thanks for a great class.

Eric

Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6349
38918 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Dec 29, 2006, 02:27:13 PM »

Smiley the latest version has this function already, now you need only to create an object and both variables are created


Last blog : Upload images for usage in TinyMCE
What a dork
*
Posts: 15
106 credits
Members referred : 0


« Reply #2 on: Dec 29, 2006, 02:40:13 PM »

hmmm, I thought I was using the lastest version.  In the header for the access_user_class.php it says v.1.94.  Is there something later?  If so, where do I get it?

Thanks for the quick response.
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6349
38918 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Dec 29, 2006, 02:49:40 PM »

oeps...

it looks like I need to release this version first Cheesy


Last blog : Upload images for usage in TinyMCE
What a dork
*
Posts: 15
106 credits
Members referred : 0


« Reply #4 on: Dec 29, 2006, 02:51:58 PM »

Ok, you had me going there for second  Grin.  Anyway, great class by the way.  I have a couple of other questions that I will be posting in new threads shortly.
Just another rainy day
*
Posts: 1
6 credits
Members referred : 0


« Reply #5 on: Jan 07, 2007, 02:45:46 PM »

Hi Olaf any chance you can post only the code that takes care of this feature?

BTW
the sample Eric submitted does not deal with the situation when there is no user logged in. The SQL will return 0 rows.
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6349
38918 credits
Members referred : 374


It's time to use PHP5!


« Reply #6 on: Jan 07, 2007, 04:15:49 PM »

Hi Olaf any chance you can post only the code that takes care of this feature?

BTW
the sample Eric submitted does not deal with the situation when there is no user logged in. The SQL will return 0 rows.

I know I need to hurry Cheesy
Will try it soon...


Last blog : Upload images for usage in TinyMCE
What a dork
*
Posts: 15
106 credits
Members referred : 0


« Reply #7 on: Jan 08, 2007, 06:30:05 AM »

kweiss,

I'm not sure I understand what your talking about with regards to not getting the user info if a user is not logged in.  How do you propose to do that?  If a user is not logged in, how does one go about determining who the user is and then doing the appropriate db lookup. 

Would be interested in hearing your thoughts because it could be really helpful to be able to do this.
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=5410
Tags : access_user Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: get_user_info and non protected pages
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Oct 11, 2008, 02:04:00 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!


Forum Statistics
Total Posts: 36.904
Total Topics: 7.557
Total Members: 4.148
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: ljay

21 Guests, 4 Users online :

14 users online today:



Readers

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