This topic is locked

random page backround in login

10/15/2023 1:42:19 PM
PHPRunner General questions
F
francesco author

I want this code working only for login page. How do I proceed?
random page background

admin 10/15/2023

Yes. In that code read the current page name and if it is "login.php" than apply the rest of the code.
https://stackoverflow.com/questions/13032930/how-to-get-current-php-page-name

francesco 10/15/2023

Thank you very much, this is correct code:
<?php // Verifica se la pagina corrente รจ "login.php" if (basename($_SERVER["SCRIPT_FILENAME"]) == "login.php") { if (!$_SESSION["background"]) { $arr = array_diff(scandir("backgrounds"), array('..', '.')); $key = array_rand($arr); $_SESSION["background"] = $arr[$key]; } echo(' <style type="text/css"> body { height: 100%; background: transparent url("backgrounds/' . $_SESSION["background"] . '") no-repeat center center fixed; background-size: cover; } </style>'); } ?>