Displaying Information

Discussion in 'Customization & add-ons' started by WindWalker, Sep 1, 2003.

  1. WindWalker

    WindWalker Guest

    Ok, I have the script working great, luv it!! :D But I want to display information about the members on all pages using the smarty template system thru-out my whole site, and if they are not logged in display a welcome andl ogin instead of the members information. Such as if you go to the site it would say welcome, would you liek to log in? so you do and then instead the message is gone after login and instead displays a memebers menu or something. Can it be done?
  2. alex-adm

    alex-adm Guest

    Sure, it is possible, use code like that:

    1. Use
    session_start();
    in top of all your PHP pages

    2. Use the following in your smarty code:
    Code:
    {if $smarty.session._amember_login}
      Hello {$smarty.session._amember_user.name_f}!
    {else}
      Please login
    {/if}
  3. komlos

    komlos Guest

    Hi,

    What code do I have to use for the same problem with the exception that I want to display info on my PHP pages, not in the smarty templates?

    Thanks
  4. WindWalker

    WindWalker Guest

    I agree, I would like to know how to do this also. I Would like to be able to only show certain content for my members and not visitors on my other php pages that are not using the smarty templates.. B)
  5. alex-adm

    alex-adm Guest

    Code:
    <?
    session_start();
    if ($_SESSION['_amember_login']){
     print "Hello " .  $_SESSION['_amember_user']['name_f'] . "!";
    } else {
     print "Please login";
    }
    ?>
    
  6. microlinx

    microlinx aMember Pro Customer

    Joined:
    Oct 26, 2004
    Messages:
    247
    Displaying number of current subscribers on home page

    Hi Alex:

    I was wondering if there is a way to dynamically display the current number of subscibers on an html page, either inside my protected area or outside the protected area, like on the home "sales" page before someone signs up, so they can see that other's are subscribed and how many.

    It just need it to be automatically updated each time someone subscribes.

    Thanks again for a GREAT script & keep up the good work!
    :D
  7. alex

    alex Administrator Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,020
    something like this:

    PHP:
    <?php
    function get_amember_users_count(){
      
    $mc mysql_connect("localhost""username""password",);
      if (!
    $mc) { print "MySQL connection failed: " mysql_error(); return -1; }
      
    $ok mysql_select_db("databasename"$mc);
      if (!
    $ok) { print "Cannot change MySQL database : " mysql_error(); return -1; }
      
    $q mysql_query("SELECT COUNT(member_id) FROM amember_members
         WHERE status > 0"
    $mc);
      if (!
    $q) { return "Query error: ".mysql_error(); return -1; }
      list(
    $c) = mysql_fetch_row($q);
      return 
    $c;
    }
    print 
    get_amember_users_count();
    ?>
  8. microlinx

    microlinx aMember Pro Customer

    Joined:
    Oct 26, 2004
    Messages:
    247
    One more request....

    Thanks Alex!

    One more question related to this:

    Is it possible to display the current number of LOGGED IN users on a page?

    This could prove useful on a download page, just in case 20 people are all downloading the same file at once...of it is slow, they would know why.

    Thanks!
  9. alex

    alex Administrator Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,020
    No, it is completely impossible.

Share This Page