I want to use this because i have to maintain a session. I tried in this way but the function is being executed immediately when the page is opened:
<a onclick="myfunction();">text</a>
Function:
function myfunction()
{
<?php
header("location: page.php");
exit;
?>
}
I tried also with forms and buttons but isn't working.
HTML
<a href="redirect.php">text</a>
redirect.php
<?php
session_start();
if($_SESSION['smth']){
header("location: page.php");
} else {
// to do what you want
}
?>