query to check current user

Discussion in 'PHP' started by Riots, Apr 7, 2010.

  1. #1
    Hey all I am trying to setup this page for example check current user and check there memberstatus and if it equal to member_individual or member_group my query just checks there memberstatus. Im sure i am missing something simple to check for current user. here my code. thanks


    <?php
    $login_form = "loginform.php";
    require "library/authorize.php"; 
    
    $query_rs1 = "SELECT * FROM USERS WHERE MEMBERSTATUS = 'Member_Individual' or MEMBERSTATUS = 'Member_Group'";
    
    if ($login != fail) { 
    ?>
    
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
      <tr>
        <td class="padder5" ><span class="textclass1"><strong>Logged In</strong></span><div align="right"><strong>( <a href="?page=account">Continue To My Account</a> )</strong></div></td>
      </tr>
    </table>
    <table width="100%" cellpadding="0" cellspacing="0" border="0" >
    
      <tr>
        <td class="padder5"><p>You have successfully logged in.</p></td>
      </tr>
      
     <tr>
       <?php if ($row_rs1['MEMBERSTATUS'] == 'Member_Individual' || $row_rs1['MEMBERSTATUS'] == 'Member_Group') {?>  <td class="padder5"><p>include community page here..</p></td><?php };?>
      </tr>
      <tr>
        <td class="padder5"><div align="right"><strong>( <a href="?page=account">Continue To My Account</a> )</strong></div></td>
      </tr>
      
    </table>
    <?php } ?>
    
    Code (markup):
     
    Riots, Apr 7, 2010 IP
  2. atlantaazfinest

    atlantaazfinest Peon

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you have connection to your database setup in one of those includes file?
     
    atlantaazfinest, Apr 7, 2010 IP
  3. Riots

    Riots Active Member

    Messages:
    374
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    83
    #3
    yes I do have a connection setup. it logs a user in and they come to this page. and based on a users memberstatus i want to show community page.
     
    Riots, Apr 7, 2010 IP
  4. atlantaazfinest

    atlantaazfinest Peon

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ok well first you need to execute the query. Im not to sure on what db etc your using so im going to guess mysql.. Also im not sure how you have your sessions or db setup because based on the query you have there isn't sufficient to grab the currently lo-gin in user. but here is a basic check.

    $result = mysql_query($query_rs1);
    if (mysql_num_rows($result) > 0) {
        [show what you want to show here, means that the query came back with a row]
    }
    Code (markup):
     
    atlantaazfinest, Apr 7, 2010 IP
  5. Riots

    Riots Active Member

    Messages:
    374
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    83
    #5
    yes i do have mysql. where exactly should i add this code? so I can do a basic check
     
    Riots, Apr 7, 2010 IP
  6. atlantaazfinest

    atlantaazfinest Peon

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    at the top of the page after the includes. to your db etc.
     
    atlantaazfinest, Apr 7, 2010 IP