';
}
$lastName=trim($lastName);
if(empty($lastName)) {
$ok=false;
echo 'The last name can not be blank
';
}
if(empty($gender)) {
$ok=false;
echo 'Please select male or female
';
}
$birthdate=mktime(0,0,0,$month,$day,$year);
//if not a valid date, such as Sept. 31, or Feb. 29 in a non-leapyear, it wraps over to next mont, ie Oct. 1 or March 1.
$format1="$month/$day/$year";
$format2=date("n/j/Y",$birthdate);
if($format1!=$format2) {
$ok=false;
echo 'The date you entered is not a valid date
';
}
if($ok) {
include($_SERVER[DOCUMENT_ROOT]."/data/connection.php");
connect();
$bday="$year/$month/$day";
$sql='INSERT INTO Patients(FirstName,LastName,Birthdate,Gender) '.
'VALUES("'.$firstName.'","'.$lastName.'","'.$bday.'","'.$gender.'")';
echo $sql.'
';
$result = mysql_query($sql);
$sql='SELECT LAST_INSERT_ID() AS ID';
$result = mysql_query($sql);
$row=mysql_fetch_array($result);
extract($row);
echo $ID.'
';
foreach($disease as $key=>$info) {
$sql='INSERT INTO Disease(ID,Disease) VALUES("'.$ID.'","'.$info.'")';
echo $sql.'
';
}
//echo 'The information is complete.
'; //can be entered in database
}
}
else echo 'Please complete all information and press submit
';
?>
';
if(isset($firstName)) echo '$firstName='.$firstName.'
';
else echo 'NO value for $firstName
';
if(isset($lastName)) echo '$lastName='.$lastName.'
';
else echo 'NO value for $lastName
';
if(isset($gender)) echo '$gender='.$gender.'
';
else echo 'NO value for $gender
';
echo "Birthdate=$month/$day/$year
";
$age=$curYear-$year;
echo 'Age='.$age.'
';
echo "Previous conditions: ";
if(isset($asthma)) echo 'asthma ';
if(isset($hypertension)) echo 'hypertension ';
if(isset($cancer)) echo 'cancer ';
echo "
Reason for visit: $reason
";
?>