Deepak Chaudhary Deepak Chaudhary - 1 year ago 67
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>";

Answer Source

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>';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download