Coding Follow/Unfollow system in CodeIgniter(PHP) & Twitter-Bootstrap. Am also having routes active for the URLS. Follow Button code in VIEW.
<!-- Follow Button Start -->
<?php $is_logged_in = $this->session->userdata('is_logged_in'); ?>
<?php if(!(empty($is_logged_in)) && $sID != $vID && !in_array($sID, $following)): ?>
<button class="btn" type="submit" onClick="location.href='<?php echo site_url("follow/$vUsername"); ?>'">Follow <?php echo $vUsername; ?> </button>
<?php elseif (in_array($sID, $following)):?>
<button class="btn" type="submit" onClick="location.href='<?php echo site_url("unfollow/$vUsername"); ?>'">UnFollow <?php echo $vUsername; ?> </button>
<?php else: ?>
<button class="btn disabled" type="submit">Follow <?php echo $vUsername; ?> </button>
<?php endif; ?>
<!-- Follow Button End -->
Even If the User is not Following than too the Button shows UnFollow $vUsername
I can’t fully test it here, but this would make more sense to me:
Edit:
Well, in that case, only simple step-by-step debugging will save you: