Deepak Chaudhary Deepak Chaudhary - 2 months ago 4x
PHP Question

Change Text and href of a tag after login

<li><a href="login.php" class="changelogin" title="Log In">Log In</a></li>

This link will go to the login page and there I will login but after login it should change the text to "profile" and and href= "userwork.php".

if (isset($_SESSION['email']))
echo "<script type='text/javascript'>";
echo "$('.changelogin').text('Profile')";
echo "$('.changelogin').attr('href', 'userwork.php')";
echo "</script>";


Why not doing something like this ?

if (isset($_SESSION['email'])) {
    echo '<li><a href="userwork.php" title="Profile">Profile</a></li>';
} else {
    echo '<li><a href="login.php" title="Log In">Log In</a></li>';