very simple login script question!

Discussion in 'PHP' started by niravdave, Sep 21, 2008.

  1. #1
    I know this is simple, but I am not a php programmer,so cannot figure it out.

    All i want to do is. when user is not logged in, he should see 'LOGIN' instead of 'SIGNOUT'. I have no idea how to do this.


      
    <li style="float: right;"><? if($_COOKIE[$ck_userid]) { ?>
    	<a href="?view=logout&signout=now" rel="nofollow"><?=$lang['SIGNOUT']; ?> </a></li>
    <?	} ?>
    
    Code (markup):
    help will be highly appreciated.

    Thanks
    Nirav
     
    niravdave, Sep 21, 2008 IP
  2. zeldaze

    zeldaze Active Member

    Messages:
    311
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    60
    #2
    If you are using sessions or cookies you can have a conditional statement checking if the session or cookie is set or not.
     
    zeldaze, Sep 21, 2008 IP
  3. niravdave

    niravdave Active Member

    Messages:
    675
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    88
    #3
    I wish i could have understood what you said. Thanks for the tip!

    Can sombody help me on altering this code rather than suggesting what to do, i don't know php.

    Thanks
    Nirav
     
    niravdave, Sep 21, 2008 IP
  4. fr0st

    fr0st Guest

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    it's simple,just erase SIGNOUT from your script and type LOGIN there.
    If it doesn't works,PM me
     
    fr0st, Sep 21, 2008 IP
  5. niravdave

    niravdave Active Member

    Messages:
    675
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    88
    #5
    HI,

    Thanks for the tip! how will this work ? as i want to use LOGIN when user is a guest. and i want LOGIN to change to SIGNOUT after the user has logged in.

    Thanks
    Nirav

     
    niravdave, Sep 21, 2008 IP
  6. redbayron2006

    redbayron2006 Active Member

    Messages:
    173
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #6
    I think that isset command will do the trick, try the following:

    
    <li style="float: right;"><? if(isset($_COOKIE[$ck_userid])) { ?>
    	<a href="?view=logout&signout=now" rel="nofollow"><?=$lang['SIGNOUT']; ?> </a></li>
    <?	} ?>
    
    Code (markup):
    For more on this command try this link to php.net site. Hope that helps really.
     
    redbayron2006, Sep 21, 2008 IP
  7. niravdave

    niravdave Active Member

    Messages:
    675
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    88
    #7
    hey redbay,

    thanks for the help! that did not do the trick...I m not sure if i am clear on what am looking for

    for guest
    <a href="login.html">login</a>

    For logged in
    <? if(isset($_COOKIE[$ck_userid])) { ?>
    <a href="?view=logout&signout=now" rel="nofollow"><?=$lang['SIGNOUT']; ?> </a>

    I am unsure on how do i switch between these two.

    Thanks
    Nirav

     
    niravdave, Sep 21, 2008 IP
  8. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #8
    <li style="float: right;">
    <? if(isset($_COOKIE[$ck_userid])) { ?>
    	<a href="?view=logout&signout=now" rel="nofollow"><?=$lang['SIGNOUT']; ?> </a></li>
    <?	} else { ?>
    	<a href="?view=login&login=now" rel="nofollow"><?=$lang['LOGIN']; ?> </a></li>
    <?	} ?>
    PHP:
    is this what u looking for?
    I assume that if the $_COOKIE[$ck_userid] is SET, the user is logged in and if it is not, the user is not logged in.

    Replace the url and $LANG of login as u wish.
    good luck
     
    ads2help, Sep 21, 2008 IP
    niravdave likes this.
  9. niravdave

    niravdave Active Member

    Messages:
    675
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    88
    #9
    what more do I say?

    You are a STAR ads2help! i really appreciate your help!

    You have solved my problem!!

    Thank you so much!

    Nirav

     
    niravdave, Sep 21, 2008 IP
  10. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #10
    Try this:
    <li style="float: right;"><?php if($_COOKIE[$ck_userid]) { echo '<a href="?view=logout&signout=now" rel="nofollow">'.$lang['SIGNOUT']. '</a>'; }else{ echo '<a href="?view=login&signin=now">'. .$lang['SIGNIN']. '</a>'; } ?></li>

    I don't know the URL which shows when you click login, so you need to edit . href after else.
    regards :)
     
    JEET, Sep 21, 2008 IP
  11. niravdave

    niravdave Active Member

    Messages:
    675
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    88
    #11
    hey jeet!

    appreciate your help! ads2help solved my problem in the prev post.

    Thanks u so much!! DP rocks guys!

    Nirav

     
    niravdave, Sep 21, 2008 IP
  12. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #12
    Wow thank you =p i hope i can help solving more problems =D
     
    ads2help, Sep 21, 2008 IP