【发布时间】:2017-02-11 22:04:27
【问题描述】:
我想使用它,因为我必须维护一个会话。 我尝试过这种方式,但是打开页面时该功能立即执行:
<a onclick="myfunction();">text</a>
功能:
function myfunction()
{
<?php
header("location: page.php");
exit;
?>
}
我也尝试过使用表单和按钮,但不起作用。
【问题讨论】:
我想使用它,因为我必须维护一个会话。 我尝试过这种方式,但是打开页面时该功能立即执行:
<a onclick="myfunction();">text</a>
功能:
function myfunction()
{
<?php
header("location: page.php");
exit;
?>
}
我也尝试过使用表单和按钮,但不起作用。
【问题讨论】:
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
}
?>
【讨论】: