请帮忙。在 form.php 中使用 $_SERVER['HTTP_REFERER'] 获得的链接如下:
<?php
$link = 'http://' . getenv('HTTP_HOST') . '/';
if (isset($_SERVER['HTTP_REFERER']) and !empty($_SERVER['HTTP_REFERER'])) {
$link = $_SERVER['HTTP_REFERER'];
$refData = parse_url($link); }
if($refData['host'] !== 'domain.com') {
die("server error"); }
?>
<p>Send this link - <?php echo htmlentities($page_url, ENT_QUOTES); ?></P>
<input name="link" type="hidden"
value="<?php echo htmlentities($page_url, ENT_QUOTES); ?>" />
<input type="submit" value="submit" />
提交表单后,referer url 切换到form.php。这段代码有问题还是有什么特定的方法可以防止引用 URL 被切换?