You appear to try generating a random background image using PHP but then do nothing with that, unless somehow you are hoping that it will exist within your stylesheet? As the stylesheet is a .css file any PHP code within will not be executed by the server so to have a dynamic style you could simply add an inline style tags to the page that sets the body background
<?php
session_start();
$png = array( 'png1.jpg', 'png2.jpeg', 'png3.jpg', 'png4.jpg' );
$random = rand(0,count($png)-1);
$picture = $png[ $random ];
?>
<!DOCTYPE HTML>
<html>
<head>
<link rel='stylesheet' href='index.css'>
<style>
body{
background-image:url(<?php echo $picture; ?>);
background-size: cover;
}
</style>
</head>
<body>
<form action='login.php' method='post'>
<label>Name: <input type='text' name='name' /></label>
<label>Password: <input type='text' name='password' /></label>
<input type='submit'>
</form>
</body>
</html>
Thinking that perhaps the above, being untested, had an issue overlooked when writing the answer I have just put together a working example using images on my system &/or on the web.
<?php
session_start();
//local images within subdirectory
$png = array( 'bck1.jpg','bck2.jpg','bck3.jpg','bck4.jpg','bck5.jpg','bck6.jpg','bck7.jpg' );
$random = rand(0,count($png)-1);
$picture = './images/' . $png[ $random ];
// globally accessible images on interwebs
$png=array(
'https://undsgn.com/wp-content/uploads/2018/04/ltotbngnzzu-uai-1600x900.jpg',
'https://cdn.wallpapersafari.com/54/86/cU6JWo.jpg',
'https://cdn.nimbusthemes.com/2017/09/09233338/Free-Nature-Backgrounds-Sunset-by-Pixabay.jpg',
'https://img.youtube.com/vi/V-FgQ2NAGFc/maxresdefault.jpg'
);
$random = rand(0,count($png)-1);
$picture = $png[ $random ];
?>
<!DOCTYPE HTML>
<html>
<head>
<style>
body{
/*
If the background image is to entirely cover the available space
and maintaining the aspect ratio is not important then you can
set the size as below. Other settings ( such as cover or 100% auto )
will cause blank space when image bounds are reached
*/
background-image:url(<?php echo $picture; ?>);
background-size: 100% 100vh;
background-repeat:no-repeat;
}
form{
width:300px;
padding:1rem;
border:1px solid silver;
background:white;
box-sizing:border-box;
border-radius:1rem;
box-shadow:0 0 25px white;
margin:2rem;
font-family:monospace;
}
label{
display:flex;
flex-direction:row;
justify-content:space-between;
align-items:center;
background:white;
margin:0.25rem 0;
}
[type='submit']{
width:100%;
padding:0.5rem;
margin:1rem 0 0 0;
}
</style>
</head>
<body>
<form action='login.php' method='post'>
<label>Name: <input type='text' name='name' /></label>
<label>Password: <input type='text' name='password' /></label>
<input type='submit'>
</form>
</body>
</html>
The above, when saved with a .php extension will yield output like this:
