Hello, I have a system that by clicking on a link, it verifies if the user is logged in and depending on this the link changes; it works well but if the user is not logged in yet he enters the section and then quickly redirects to the page I want, the idea is that he does not enter the section but redirects at once to the page I want.
<div id="r">
<?php
foreach ($mysqli->query('SELECT * FROM r') as $fila) {
echo "<div class='card-action'>
<a href='"; echo isset($_SESSION['id']) ? "#" : "./gin.php"; echo "' class='rr'>reservar</a>
<input type='text' value='".$fila['id']."'>
</div>";
}
?>
</div>
<script>
$(document).ready(function(){
$("#r").on('click','a.rr',function(){
var id = $(this).siblings('input').val();
$.ajax({
type: "GET",
url: "vation.php",
data: { id:id },
success: function(data) {
$('#r').html(data);
}
});
});
});
</script>
An example of the closest thing I need would be to book something; if the user is registered, he continues normally otherwise he should take it to register and not allow the normal flow.