Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/264328-button-help/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/264328-button-help/#findComment-1354639
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.