Question: Can someone pleaseee tell me what am I doing wrong with this code? The php part changes when I save the entire file as html.

Can someone pleaseee tell me what am I doing wrong with this code? The php part changes when I save the entire file as html. Im not sure what the problem is? Id appreciate a second set of eyes! Thank you!

Birthday

Is Today Your Birthday?!!

if(isset($_POST['sub']))

{

$mm=$_POST['mm'];

$dd=$_POST['dd'];

$yy=$_POST['yy'];

$dob=$mm ."/".$dd."/".$yy;

$arr=explode('/',$dob);

//$dateTs=date_default_timezone_set($dob); $dateTs=strtotime($dob);

$now=strtotime('today');

if(sizeof($arr)!=3) die('ERROR:please entera valid date');

if(!checkdate($arr[0],$arr[1],$arr[2])) die('PLEASE: enter a valid dob');

if($dateTs>=$now) die('ENTER a dob earlier than today');

$ageDays=floor(($now-$dateTs)/86400);

$ageYears=floor($ageDays/365);

$ageMonths=floor(($ageDays-($ageYears*365))/30);

echo " You are $ageYears years old. "; if($mm==$arr[0]) { if($dd==$arr[1]) echo" Today is your birthday"; } }

?>

Enter your DOB

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!