Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

i have a HTML code my website is aankitmalhotra.com when i click on the contact

ID: 3551770 • Letter: I

Question

i have a HTML code my website is


aankitmalhotra.com


when i click on the contact page and type in the info and press submit it does not calcualte the age correctly


can someone edit my code and help me


the code that i have on my contactform.php is




<!DOCTYPE html PUBLIC "//WC3//DTD XHTML 1.0 Transitional//EN" "http">

<!-- saved from url=(0036)http://andrewjlee.info/Contacts.html -->

<html xm1n="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<head>

<title>Contact</title>

<link rel="stylesheet" type="text/css" href="main.css" />

</head>


<script>

function submitBday() {

var Q4A = "You are ";

var Bdate = document.getElementById('bday').value;

var Bday = +new Date(Bdate);

Q4A += + ~~ ((Date.now() - Bday) / (31557600000)) + " years old.";

var Age = ((Date.now() - Bday) / (31557600000))

var theBday = document.getElementById('resultBday');

var theEligebility = document.getElementById('resultEligebility');

theBday.innerHTML = Q4A;

if (Age<18)

{

theEligebility.innerHTML = "You are Eligeble for a youth discount!"

}

else if (Age>50)

{

theEligebility.innerHTML = "You are Eligeble for a senior discount!"

}

else

{

theEligebility.innerHTML = ""

}

}

</script>

  

</head>



<body>



<body>

<div id="page">

<div id="header">

<img src="images/me.jpg" alt="Picture of Ross Aankit Malhotra" width="100px" height="90px" />

<h1>Aankit Malhotra</h1>

<h3>MIS student with a dream</h3>

</div>

<div id='cssmenu'>

<ul>

<li><a href="index.html"><span>Home</span></a></li>

<li><a href="hobbies.html"><span>Hobbies</span></a></li>

<li class='portfolio.html'><a href="#"><span>Portfolio</span></a></li>

<li class='active'><a href="contact.html"><span>Contact</span></a></li>

</ul>

</div>

</div>


<div id="main">

<center>

<br>

<br>

<div align="center">

<h1>Thank you for contacting me!</h1>

<p><br>

Welcome <?php echo $_POST["first_name"]; ?><br />

<br>

<?php


$ageTime = mktime($agetime); // Get the person's birthday timestamp

$t = time(); // Store current time for consistency

$age = ($ageTime < 0) ? ( $t + ($ageTime * -1) ) : $t - $ageTime;

$year = 60 * 60 * 24 * 365;

$ageYears = $age / $year;


echo 'You are ' . floor($ageYears) . ' years old.';


?>

<?php

if ($adjustedage<"18")

{

echo "Your age is $adjustedage and your eligible for the youth discount!";

}

else if ($adjustedage>"50")

{

echo "Your age is $adjustedage and your eligible for the senior discount";

}

else

{

echo "Your age is $adjustedage and you are not eligible for any discounts at this time";

}

?>


<br />

<br />

Your email address is: <?php echo $_POST["email"]; ?><br />

Your telephone number is: <?php echo $_POST["telephone"]; ?><br />

Your address is: <?php echo $_POST["address"]; ?><br />

Your city is: <?php echo $_POST["city"]; ?><br />

Your zip is: <?php echo $_POST["zip_code"]; ?><br />

Your state is: <?php echo $_POST["State"]; ?><br />

Your date of birth is: <?php echo $_POST["bday"]; ?><br />

You commented: <?php echo $_POST["comments"]; ?><br />   

  

<br>

<script type="text/javascript">

function numbersonly(myfield, e, dec)

{

var key;

var keychar;


if (window.event)

key = window.event.keyCode;

else if (e)

key = e.which;

else

return true;

keychar = String.fromCharCode(key);


// control keys

if ((key==null) || (key==0) || (key==8) ||

(key==9) || (key==13) || (key==27) )

return true;


// numbers

else if ((("0123456789-()").indexOf(keychar) > -1))

return true;


// decimal point jump

else if (dec && (keychar == "."))

{

myfield.form.elements[dec].focus();

return false;

}

else

return false;

}


//-->

</script>

</p>







</div></div></body></html>

Explanation / Answer

you can't subtract the whole date. just subtract the years to calculate the correct age.

for eg:

var d = new date();

var curr_year= d.getFullYear();

var Bday_year= bday.getFullYear();

age=curr_year-Bday_year;

try this. it will work