Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Member HAViK's Avatar
    Join Date
    Aug 2004
    Location
    Perris, CA
    Posts
    50
    Member #
    6930
    After logging in how would I pull a customer id associated with the user name they used to log in? I need to be able to have this carried over on every page (through one of my requires... I have a require called application_top.php) so that it can be accessible as a variable. Maybe have it posted so I can just use like (int)$HTTP_GET_VARS['customers_id'] for my sql queries.

    I'm matching up a customer id between two of my tables to show products for a specific customer that has logged in (a custom product re-ordering site) and I'm having trouble. here is what I want to do in my 'where' clause

    PHP Code:
    // show products for a logged in customer
        
    if (isset($HTTP_GET_VARS['customers_id'])) {
    // showing products in a certain category for only a specific customer
            
    $listing_sql "select " $select_column_list " p.products_id, p.customers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " TABLE_PRODUCTS " p, " TABLE_PRODUCTS_DESCRIPTION " pd, " TABLE_CUSTOMERS " m, " TABLE_PRODUCTS_TO_CATEGORIES " p2c left join " TABLE_SPECIALS " s on p.products_id = s.products_id where p.products_status = '1' and p.customers_id = m.customers_id and m.customers_id = '" . (int)$HTTP_GET_VARS['customers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";
          } else {
    // otherwise just display all products for customer
            
    $listing_sql "select " $select_column_list " p.products_id, p.customers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " TABLE_PRODUCTS " p, " TABLE_PRODUCTS_DESCRIPTION " pd, " TABLE_CUSTOMERS " m left join " TABLE_SPECIALS " s on p.products_id = s.products_id where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id "' and p.customers_id = m.customers_id and m.customers_id = '" . (int)$HTTP_GET_VARS['customers_id'] . "'";
          } 
    Filter ID is to display just a specific category.

    So I'm just looking really for how I can hit up a table after log-in, grab the customer_id from the table while making sure that it matches up with the username used to log-in with, and then carry it over in one of my includes so that it is always accessible as a variable, or maybe something else?

    I appreciate it folks.
    SORIA Inc. My First Stab At Creating A Site...

  2.  

  3. #2
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    137 times
    Use sessions to carry over variables to various pages.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  4. #3
    Member HAViK's Avatar
    Join Date
    Aug 2004
    Location
    Perris, CA
    Posts
    50
    Member #
    6930
    Quote Originally Posted by Wired
    Use sessions to carry over variables to various pages.
    I have a session running, I'm just unsure as to how to have this passed? Is it a code that sits at the top of the page or something? I'm simply modifying the hell out of osCommerce to make it members only and re-doing sizing charts and such, but this is my FIRST php project, so it's kind of harsh on me.

    EDIT:
    ... actually second, but my first was nowhere near this caliber. It was a simple member website for information, check to see if this person is logged in and search a database for entries.

    EDIT:
    Would I use like session_register($variable); ?
    SORIA Inc. My First Stab At Creating A Site...

  5. #4
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    137 times
    Yep. register the var in the session.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:53 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com