按div时重定向

I am trying to get it when someone presses the div that it will give an alert en after a view seconds it will redirect automatic.

My php code:

<?php
    if(!isset($_SESSION['USER'])) { ?>
        <a href="autohuren.php">
            <div class="btn btn-outline btn-default" style="background-color:white;">
                Huur deze auto.
            </div>  
        </a>
<?php } ?>

This code will redirect but not when pressing the div. And their is no alert.

if(!isset($_SESSION['USER'])) { 
echo "Please Log In First";
echo "<script>setTimeout(\"location.href = 'http://www.forobd2.com';\",1500);</script>";
} ?>

So what I want is that the div when pressed alert with a message and redirect after a few seconds. I hope someone can help me with this!

You first need to remove the default event on the link. Then you need to wait 2 seconds and make a redirect.

<a id="link" href="autohuren.php">
    <div class="btn btn-outline btn-default" style="background-color:white;">
        Huur deze auto.
    </div>  
</a>


<script type="text/javascript">         
document.querySelector('[href="autohuren.php"]').addEventListener("click", function(event) {
    event.preventDefault();
    <?php if(isset($_SESSION['USER'])) { ?>
    window.setTimeout(function(){ 
        window.location.replace("autohuren.php");
    },2000);
    <?php }else{ ?>
    alert('Please Log In First');
    <?php } ?>
}, false);
</script>