I have a problem with my website project using PHP. How can I disable link (ex : register.php and login.php) when admin click button for disable link in admin panel, and enable that again when it clicked for the second time..
Anyone can help ? thanks
Store the admin selection in a database and set that property when the user loads that page.Assuming you are using raw PHP,just add disabled when admin is disabled and romove the disabled property when it is enabled
<a href="" <?php echo $status?'disabled':''>/>
If you need to deny access to those pages,then disabling the link is not enough,since the user can directly type the URL on the browser and access them. I am assuming you are using raw PHP. You need to check access status first at the beginning of register.php as below
<?php
function accessIsAllowed(){
$allowed=false;
......
//Check admin status from database
.....
return $allowed;
}
if(!accessIsAllowed){
header('Location':'Your preferred URL'); //Redirect to your preffered URL eg access denied page
}
....
?>
And on the view:
<html>
.....
<a href="register.php" <?php echo $allowed?'':'disabled';?>></a>
......
</html>
To disable the link based on admin preference