2013-08-19 75 views
0

好的,所以我有maconbeercompany.com,它有一个年龄验证重定向。它适用于IE,Chrome,Safari和Firefox。唯一的问题是我无法使它与移动设备兼容。当在iPhone或Android上时,除非点击“否”,否则我不能离开年龄验证页面。我希望用户能够点击“是”并访问啤酒公司的网站。以下是代码。我究竟做错了什么?重定向页面在移动时不重定向

<?php 
// This code, including the enclosing ?php tags, will require age verification for this page if included at the beginning of the associated HTML/PHP file. 
session_start(); 
if (!isset($_SESSION['age_verified']) || $_SESSION['age_verified'] != true) 
{ 
    // Direct them to the age verification page 
    $redirect_url = urlencode("http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF']); 

    header('Location: http://maconbeercompany.com/age-verification.php?redirect=' . $redirect_url); 
} 
?> 

感谢您的帮助!

+0

你想将其存储在会话??如果你为什么?你不用做更多的验证,只重定向...为什么不使用链接''? – Tiago

+0

你有使用移动设备来测试这个,启用cookies吗? – Lissy

+0

@Tiago他可能希望它记住用户的回答,所以他们不必验证他们的年龄 – Lissy

回答

0

有时头不与会话工作非常好,所以我会建议您尝试:

$redirect_url = urlencode("http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF']); 

echo "<meta http-equiv=refresh content='0; url=http://maconbeercompany.com/age-verification.php?redirect=". $redirect_url."'>"; 
+0

@Lissy是对的。我需要会话,因为我需要验证才能在网站的所有页面上工作。例如,如果Tom直接进入关于我们的页面,我不希望任何人能够绕过年龄验证。但与此同时,我不希望每个访问者都必须为他们访问的每个页面进行验证。 – user2696817

+0

那么我在那里使用的代码应该工作。 – Tiago

+0

我是所有这些编码的新手,所以我非常感谢您的帮助! @Fred -ii-我在哪里可以放置该代码?在标题中? – user2696817

0
“; 回声” window.open(``地点:http://maconbeercompany.com/age- ?verification.php重定向=`$ REDIRECT_URL`,`_parent`,``) “; 回声”“; } >