What am i doing wrong with my first PHP code
Posted: Sat May 22, 2010 1:53 am
i am building a website for an alcohol related company, and i need age conformation code, which asks for users birth date, then checks if that person is over 21 years old, and decides to let him/her in or no.
the form i have in the first page of the website is
the c1.php file looks like
What am i doing wrong here, when i use it, and input 2006 as year, it still takes the customer to the website
the form i have in the first page of the website is
Code: Select all
<form action="c1.php", method="POST">
<input name="day" type="text" value="DD" size="10" maxlength="2">
<input name="month" type="text" value="MM" size="10" maxlength="2">
<input name="year" type="text" value="YYYY" size="10" maxlength="4">
<input type="submit" value="GO!">
</form>Code: Select all
<html>
<head>
<title></title>
</head>
<body>
<?php
$y=date('Y');
$m=date("m");
$d=date("d");
$year=$_POST["year"];
$month=$_POST["month"];
$day=$_POST["day"];
$year2=$y-$year;
if($year2>21)
{
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=indexyes.html">';
}
if($year2<21)
{
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=indexno.html">';
}
if($year2=21)
{
if($month>$m)
{
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=indexyes.html">';
}
if($month<$m)
{
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=indexno.html">';
}
if($month=$m)
{
if($day>$d)
{
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=indexyes.html">';
}
if($day<$d)
{
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=indexno.html">';
}
if($day=$d)
{
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=indexyes.html">';
}
}
}
?>
</body>
</html>