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
Post a Comment