marquel2k69 Posted June 17, 2012 Share Posted June 17, 2012 Hi all I need a little help how would I code a button in php that checks to see if you are logged in for example if the button was labled "my account" if you were logged in it would take you to "my account" but if you weren't logged in on the button roll over it would say log in and to you to the log in/register page thanks in advance for any help if php isn't what I should be using what should I use Quote Link to comment https://forums.phpfreaks.com/topic/264328-button-help/ Share on other sites More sharing options...
PeoMachine Posted June 17, 2012 Share Posted June 17, 2012 The button will be created in HTML, but you can echo him with the php. Try something like that <?php function authenticate() { // Your authentication logic here } // If user is loged in if(authenticate()) { echo '<a href="/user-acount">My account</a>'; } // If user need to login else { echo '<a href="/login">Log in</a>'; } It will prints out a link. You can customize the link with CSS and an image, if you want to. Quote Link to comment https://forums.phpfreaks.com/topic/264328-button-help/#findComment-1354639 Share on other sites More sharing options...
ManiacDan Posted June 17, 2012 Share Posted June 17, 2012 usually this is handled by checking on the "my account" page. If they're not logged in, kick them to the login page. Quote Link to comment https://forums.phpfreaks.com/topic/264328-button-help/#findComment-1354665 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.