Help with Age Verification file
-
Hi everyone, so I’m currently running a website that has age restricted content, and anyone under the age of 21 is not supposed to view it.
So here’s my question, I’m using an age verification file that a friend of mine wrote, but whenever you confirm your age, it brings you to the correct page, but the text from the age verification is still there. You can see for yourself at https://realmccoyspirits.com.
Here’s the PHP age verifier I’m using:
<body <?php body_class(); ?>> <div id="customavcss"> <div class="avcustomtext"> Taste and Quality<br>come with age,<br>are you of age? <p>You must be of legal drinking age to view this website.</p> </div> <?php if ($_SESSION['AgeVerify'] != "clear") { if($_POST['submitteds'] != "") { $minimumagetoviewsite = 21; $birthmonth = $_POST['monthofbirth']; $birthdate = $_POST['dateofbirth']; $birthyear = $_POST['yearofbirth']; $todaysmonth = date("n"); $todaysdate = date("j"); $todaysyear = date("Y"); if(($birthyear + $minimumagetoviewsite)<$todaysyear) { $yearcheck = "okay"; } else if(($birthyear + $minimumagetoviewsite)>$todaysyear) { $yearcheck = "no"; } else { $yearcheck = "same"; } if($birthmonth < $todaysmonth) { $monthcheck = "okay"; } else if($birthmonth > $todaysmonth) { $monthcheck = "no"; } else { $monthcheck = "same"; } if($birthdate <= $todaysdate) { $datecheck = "okay"; } else { $datecheck = "no"; }; if ($yearcheck=="okay") { $agecheck = "pass"; } else if ($yearcheck=="no") { $agecheck = "fail"; } else { if ($monthcheck=="okay") { $agecheck = "pass"; } else if ($monthcheck=="no") { $agecheck = "fail"; } else { if ($datecheck=="okay") { $agecheck = "pass"; } else if ($datecheck=="no") { $agecheck = "fail"; } } } if($agecheck=="pass") { $_SESSION['AgeVerify'] = "clear"; ?> <?php } else { ?> <div class="avtooyoung"> <p>Sorry, but it looks like you're too young to view this website.</p> </div> <?php }; ?> <?php } else { ?> <form method="post" action=""> <select name="monthofbirth"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>8</option> <option>9</option> <option>10</option> <option>11</option> <option>12</option> </select> <select name="dateofbirth"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>8</option> <option>9</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> <option>15</option> <option>16</option> <option>17</option> <option>18</option> <option>19</option> <option>20</option> <option>21</option> <option>22</option> <option>23</option> <option>24</option> <option>25</option> <option>26</option> <option>27</option> <option>28</option> <option>29</option> <option>30</option> <option>31</option> </select> <select name="yearofbirth"> <option>1920</option> <option>1921</option> <option>1922</option> <option>1923</option> <option>1924</option> <option>1925</option> <option>1926</option> <option>1927</option> <option>1928</option> <option>1929</option> <option>1930</option> <option>1931</option> <option>1932</option> <option>1933</option> <option>1934</option> <option>1935</option> <option>1936</option> <option>1937</option> <option>1938</option> <option>1939</option> <option>1940</option> <option>1941</option> <option>1942</option> <option>1943</option> <option>1944</option> <option>1945</option> <option>1946</option> <option>1947</option> <option>1948</option> <option>1949</option> <option>1950</option> <option>1951</option> <option>1952</option> <option>1953</option> <option>1954</option> <option>1955</option> <option>1956</option> <option>1957</option> <option>1958</option> <option>1959</option> <option>1960</option> <option>1961</option> <option>1962</option> <option>1963</option> <option>1964</option> <option>1965</option> <option>1966</option> <option>1967</option> <option>1968</option> <option>1969</option> <option>1970</option> <option>1971</option> <option>1972</option> <option>1973</option> <option>1974</option> <option>1975</option> <option>1976</option> <option>1977</option> <option>1978</option> <option>1979</option> <option>1980</option> <option>1981</option> <option>1982</option> <option>1983</option> <option>1984</option> <option>1985</option> <option>1986</option> <option>1987</option> <option>1988</option> <option>1989</option> <option>1990</option> <option>1991</option> <option>1992</option> <option>1993</option> <option>1994</option> <option>1995</option> <option>1996</option> <option>1997</option> <option>1998</option> <option>1999</option> <option>2000</option> <option>2001</option> <option>2002</option> <option>2003</option> <option>2004</option> <option>2005</option> <option>2006</option> <option>2007</option> <option>2008</option> <option>2009</option> <option>2010</option> <option>2011</option> <option>2012</option> </select> <input type="hidden" name="submitteds" value="yes"> <input type="submit" name="verify" value="verify"> </form> </div> <?php exit; } }; ?> </div>
So I’ve put that just below the
</head>
in the header.php file.Also, in my wp-config, at the very top of the paged, it was changed from
* @package WordPress */ // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */
to this:
* @package WordPress */ session_start(); // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */
If anyone knows how I could fix this so that when you confirm your age, the age verifier disappears and you are brought to the home page that would be great!
Have a nice day ??
-Finn
- The topic ‘Help with Age Verification file’ is closed to new replies.