php - How to create different button based on a condition? -


how create button based on status. let's if i'm not logged in login, button direct login page, if not, button direct logout page. can tell me how in php? attempt:

$loginstatus = false;  session_start(); if(isset($_session['loginname'])){   $loginstatus = true;   } else {   $loginname = "guest"; } 

something this?

<?php $loginstatus = false;  session_start(); if(isset($_session['loginname'])) { ?>   <a class="button" href="logout/path">logout</a> <?php  } else { ?>    <a class="button" href="login/path">logout</a> <?php } ?> 

in case use <a> tag, if want use regular button can javascript or form.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -