keyboard
11-02-2011, 12:43 AM
Hey everyone!
I've written this script
<?php
$bday = $_POST['day'];
$bmonth = $_POST['month'];
$byear = $_POST['year'];
$cday = date('j');
$cmonth = date('n');
$cyear = date('Y');
$one = "1";
if($cmonth != "$bmonth"){
if($cmonth > "$bmonth"){
$age = $cyear-$byear;
echo $age;
}else{
if($cmonth < "$bmonth"){
$age = $cyear-$byear-$one;
echo $age;
}
}
}else{
if($cmonth == "$bmonth"){
if($cday != "$bday"){
if($cday > "$bday"){
$age = $cyear-$byear;
echo $age;
}else{
if($cday < "$bday"){
$age = $cyear-$byear-$one;
echo $age;
}
}
}else{
if($cday =="$bday"){
echo "Happy Birthday";
}
}
}
}
?>
to calculate the age of a user and echo their age(for testing perposes).
The problem is I think I mixed up where so of the { and } are ment to go because its echoing either -1 or 0 depening on what I input into the form(whch submits to this script)
The birthay is in this format
2 11 2011
(2nd of november)
Any help?
I've written this script
<?php
$bday = $_POST['day'];
$bmonth = $_POST['month'];
$byear = $_POST['year'];
$cday = date('j');
$cmonth = date('n');
$cyear = date('Y');
$one = "1";
if($cmonth != "$bmonth"){
if($cmonth > "$bmonth"){
$age = $cyear-$byear;
echo $age;
}else{
if($cmonth < "$bmonth"){
$age = $cyear-$byear-$one;
echo $age;
}
}
}else{
if($cmonth == "$bmonth"){
if($cday != "$bday"){
if($cday > "$bday"){
$age = $cyear-$byear;
echo $age;
}else{
if($cday < "$bday"){
$age = $cyear-$byear-$one;
echo $age;
}
}
}else{
if($cday =="$bday"){
echo "Happy Birthday";
}
}
}
}
?>
to calculate the age of a user and echo their age(for testing perposes).
The problem is I think I mixed up where so of the { and } are ment to go because its echoing either -1 or 0 depening on what I input into the form(whch submits to this script)
The birthay is in this format
2 11 2011
(2nd of november)
Any help?