// This code is copyrighted material owned by W. D. Bricker, doing business
// as US-Webmasters.com. Copyright 1998-2004 - All rights reserved.
//
// A single license for this code has been granted to
// US-Webmasters.com
//
// for use on site(s):
// US-Webmasters.com and related sites
//
// No other rights are implied nor shall be inferred. This code may
// not be altered, copied or distributed without express permission.
// Violation of these rights will necessitate legal remedial action.
// To get rid of "the Undefined variable: DOCUMENT_ROOT" error:
// The Root Directory:
// This worked in PHP4:
// $RootDir = $RootDir;
// This works in PHP5:
$RootDir = $_SERVER['DOCUMENT_ROOT'];
// $RootDir = $RootDir."/testing";
// Echo "DOCUMENT_ROOT: ".$RootDir."
\n";
// Echo "RootDir: ".$RootDir."
\n";
// We'll need access to the Global Variables:
// include_once("$DOCUMENT_ROOT/include/GlobalVars.php");
include_once("$RootDir/include/GlobalVars.php");
// We will be accessing all sorts of functions:
//include_once("$DOCUMENT_ROOT/include/Functs.php");
include_once("$RootDir/include/Functs.php");
// Check to see if the visitor (USER_AGENT) is a spider. If not:
// then do a "session_start"...
// Creates a session or resumes the current one
// based on the current session id that's being passed via a
// request, such as GET, POST, or a COOKIE.
// It's necessary that this be the first PHP command in the file.
If (!ItsASpider())
{
session_start();
// Sets various session variables like ReferringURL and EntryURL
// if they haven't already been set
//include_once("$DOCUMENT_ROOT/include/SetSessionVars.php");
include_once("$RootDir/include/SetSessionVars.php");
}
// This turns on Output Buffering. This seems to be
// necessary because we may be redirecting to a "Thank You" page
// after they submit the form. Speeds things up because
// browser doesn't reload when hitting BACK button.
ob_start();
// Categories according to:
// http://www.halls.md/body-mass-index/overweight.htm
// Page variables:
$PageNameStr="Online Body Mass Index Calculator (BMI) * Calculate Body Mass Index (BMI) * BMI Calculation * Calculate BMI";
$PageTitleStr="Body Mass Index Calculator (BMI) * Calculate Body Mass Index (BMI) * BMI Calculation * Calculate BMI";
$PageKeywordStr="BMI, BMI Calculator, Baby BMI, Body Mass Index Calculator, BMI Chart, BMI Index, Calculate BMI, BMI Calculation, Calculate Body Mass Index, BMI Child, Calculating BMI, BMI Body Mass Index, Body Mass Index Calculation, BMI Test, BMI Formula, BMI Scale, BMI And Weight, Find Out Your BMI, BMI Table, BMI Kid, BMI Calc, BMI Calculator Child, Over Weight BMI, Healthy BMI, Figure My BMI, BMI Over Weight Obese Chart, Body Fat BMI Calculator, BMI Chart For Child, Measure My BMI, BMI Calculator Free, BMI Body Mass Index Calculator, Check My BMI, Body Mass Calculation, BMI Measurement, Whats My BMI, BMI Index Calculator, Ideal BMI, Body Definition Index Mass, BMI Figuring, Online BMI, BMI Determine, Body Mass Index Calculator Online, Body Determine Index Mass";
$PageDescriptionStr="BMI - Body Mass Index. This page will calculate BMI for you online.";
$PageCommentStr="BMI, Body Mass Index, BMI Calculator, Baby BMI, Body Mass Index Calculator, BMI Chart, BMI Index, Calculate BMI, Body Mass, Body Mass Index Chart, BMI Calculation, Body Building Mass, Calculate Body Mass Index, BMI Child, Lean Body Mass, Body Mass Calculator, Calculating BMI, BMI Body Mass Index, Body Mass Index Calculation, Body Mass Indicator, BMI Test, BMI Formula, Body Mass Index Formula, BMI Scale, BMI And Weight, Find Out Your BMI, BMI Table, BMI Calculator Md Web, BMI Nhlbisupport.Com, Calculating Body Mass Index, BMI Kid, BMI Baby.Com, Baby BMI Flight, BMI Calc, BMI Calculator Child, Over Weight BMI, Healthy BMI, Figure My BMI, Body Mass Index Scale, Body Mass Index Table, BMI Over Weight Obese Chart, Body Fat BMI Calculator, BMI Chart For Child, Body Mass Chart, Measure My BMI, BMI Calculator Free, BMI Body Mass Index Calculator, Check My BMI, Body Mass Calculation, BMI Indicator, BMI Measurement, Equation to work out my BMI, Calculate Body Mass, Whats My BMI, Body Calculator Lean Mass, Body Mass Indes, Find My Body Mass Index, BMI Index Calculator, BMI Obesity, BMI Teen, BMI Md Web, Ideal BMI, BMI Counter, BMI Exercise Equipment, BMI Weight Chart, BMI Supply, BMI Celebrity, BMI For Man, BMI Update.Com, BMI Equation, Body Definition Index Mass, BMI For Woman, Body Computer Index Mass Scale, Anorexia BMI, BMI Measuring, Body Fat Mass, Body Ideal Mass, 23 BMI, BMI Free, Kid BMI Calculator, Weight Loss BMI, BMI Pediatric, BMI BMIcalc.Htm Nhlbisupport.Com, BMI Calculator Teen, BMI Finding, Body Idex Mass, BMI Definition, BMI Figuring, Online BMI, Age BMI, BMI Cdc, BMI Determine, Calulate BMI, BMI Index Chart, BMI Insurance, BMI Book, Measure Body Mass Index, BMI Fcu, Body Mass Ratio, Baby BMI Uk, BMI Body Fat, BMI Watcher Weight, Body Mass Index Equation, Adult BMI, BMI Chart Growth, BMI Trap, Calulate Body Fat, Body Fat Mass Index, Body Mass Scale, Body Index Mass Obesity, Figure Body Mass Index, Athlete Body Index Mass, Build Body Mass, Body Calculator Indicator Mass, Body Mass Index For Man, Body Mass Index.Com, Body Mass Index Test, Gain Body Mass, BMI.Htm Body Halls.Md Index Mass, BMI Body Chart Index Mass, Body Index Mass Woman, Body Index Mass Pediatric, BMI Body Mass, Body Building Mass Routine, Age Body Index Mass, Body Index Information Mass, Body Index Male Mass, Body Formula Mass, Body Mass Index Calculator Online, Body Calculate Lean Mass, Body Canada Index Mass, Body Inde Mass, Body History Index Mass, Body Female Index Mass, Body Mass Index Measurement, Body Building Diet Mass, Body Determine Index Mass, Body Mass Index Celebrity";
$PageRobotsStr="All";
$PageFirstLineStr="BMI Calculator * Body Mass Index Calculator";
// include_once("$DOCUMENT_ROOT/include/header.php");
include_once("$RootDir/include/header.php");
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// The variables that probably need to be changed are listed *BELOW*.
//
// This is the FormName. It will be part of the subject line of
// the resulting email.
$FormName = "Response from BMI Calculator";
// This should be the domain name that we are working with.
$ThisDomainName = $CompanyDomain;
//$ThisDomainName = "US-Webmasters.com";
// $SendEmailTo: the email address that you want to have
// the information sent to. It is of the form: Joe@JoesDomain.com
// $recipient = "Dinky@A7H.com";
$SendEmailTo = "BMI@US-Webmasters.com";
// Bcc emails: If you want these addresses to also be
// sent this information. Separate items with commas ","
// $Bcc = "BCC@US-Webmasters.com, xyz2041@GMX.net, InfoSubmit@GMX.net, WebDesignResume@GMX.net, xyz@NetINS.net";
// Once we have sent the email, this is the place we
// want the browser to go to:
// $Redirect = "http://www.US-Webmasters.com/Thank-You";
$Redirect = "";
// Note well: It is advisable to include as many variations
// of the domain as possible in the input array:
// $RefAry = array("www.US-Webmasters.com", "US-Webmasters.com", "209.152.117.178");
// as opposed to:
// $RefAry = array("US-Webmasters.com");
$RefAry = array("www.US-Webmasters.com", "US-Webmasters.com", "209.152.117.178");
// NOTE! the above ^^^^^ may not be necessary since most of this
// code will not be exposed to the public!!!!!!!!!!!!
// $BannedEmailList: email addresses that are blocked from sending
// using this PHP form.
$BannedEmailList = array("*@somedomain.com", "user@banned.com", "etc@domains.com");
// The variables that probably need to be changed are listed *ABOVE* ^^^^^.
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
///////////////////////////////////////////////////////
// Functions begin:
///////////////////////////////////////////////////////
// This is the NEW BMI check: (2004 Jan 12)
///////////////////////////////////////////////////////
function FieldsErrorCheck(&$ErrMsgArray, &$FieldErrArray)
{
// Return 0 if no errors and 1 if there are errors
// Global variables:
global $FirstName, $LastName, $EmailAddress, $BannedEmailList, $WeightKg, $HeightMt;
// OLD!!!! global $FirstName, $LastName, $WeightKg, $HeightMt, $EmailAddress, $HeightError, $WeightError, $EmailErrStr;
// Define the Error Message Array: $ErrMsgArray
// This contains all of the error messages.
// Different fields *COULD* have more than one error.
// The format of a field is something like:
// $ErrMsgArray[] = "There is something wrong with the ZIP CODE.";
$ErrMsgArray = array();
// Define the Field Error Array: $FieldErrArray
// This array contains a boolean variable for
// each POST variable. The format of this field
// is something like:
// $FieldErrArray["ZipCode"] = 1;
$FieldErrArray = array();
// Initialize the flags
$ErrorsPresent = 1;
$NoErrors = 0;
If (!$FirstName)
{
$ErrMsgArray[] = "Please enter your FIRST NAME.";
$FieldErrArray["FirstName"] = 1;
}
else
{
$FirstNameErrStr = ValidateField($FirstName, "Name");
If (($FirstName) && (!($FirstNameErrStr == "OK")))
{
$ErrMsgArray[] = "First Name seems incorrect.";
$FieldErrArray["FirstName"] = 1;
} // End IF
}
If (!$LastName)
{
$ErrMsgArray[] = "Please enter your LAST NAME.";
$FieldErrArray["LastName"] = 1;
}
else
{
$LastNameErrStr = ValidateField($LastName, "Name");
If (($LastName) && (!($LastNameErrStr == "OK")))
{
$ErrMsgArray[] = "Last Name seems incorrect.";
$FieldErrArray["LastName"] = 1;
} // End IF
}
If (!$EmailAddress)
{
$ErrMsgArray[] = "Please enter your EMAIL ADDRESS.";
$FieldErrArray["EmailAddress"] = 1;
}
else
{
$EmailErrStr = ValidateField($EmailAddress, "SingleEmail");
If (($EmailAddress) && (!($EmailErrStr == "OK")))
{
$ErrMsgArray[] = "EMAIL ADDRESS seems incorrect.";
$FieldErrArray["EmailAddress"] = 1;
}
}
// If we've set up some banned email addresss,
If ($BannedEmailList)
{
// then let's check to see if the current user
// has been banned.
$ThisEmailBanned = EmailIsBanned($BannedEmailList, $EmailAddress);
If ($ThisEmailBanned)
{
$ErrMsgArray[] = "This email address is not allowed to activate this form.";
$FieldErrArray["EmailAddress"] = 1;
}
} // End: If ($BannedEmailList)
$WeightError = 0;
$FieldErrArray["WeightKg"] = 0;
If (!$WeightKg)
{
$WeightError = 1;
$FieldErrArray["WeightKg"] = 1;
$ErrMsgArray[] = "Please enter WEIGHT.";
}
If (($WeightKg) && ($WeightKg < 2))
{
$WeightError = 1;
$FieldErrArray["WeightKg"] = 1;
$ErrMsgArray[] = "WEIGHT too small.";
}
If (($WeightKg) && ($WeightKg > 400))
{
$WeightError = 1;
$FieldErrArray["WeightKg"] = 1;
$ErrMsgArray[] = "WEIGHT too big.";
}
$HeightError = 0;
If (!$HeightMt)
{
$HeightError = 1;
$FieldErrArray["HeightMt"] = 1;
$ErrMsgArray[] = "Please enter HEIGHT.";
}
If (($HeightMt) && ($HeightMt < .3))
{
$HeightError = 1;
$FieldErrArray["HeightMt"] = 1;
$ErrMsgArray[] = "HEIGHT too small.";
}
If (($HeightMt) && ($HeightMt > 4))
{
$HeightError = 1;
$FieldErrArray["HeightMt"] = 1;
$ErrMsgArray[] = "HEIGHT too big.";
}
// How many errors?
$ErrorCount = count($ErrMsgArray);
// If there are errors, then return true, otherwise false
return ($ErrorCount) ? $ErrorsPresent : $NoErrors;
} // End: function FieldsErrorCheck(&$ErrMsgArray)
///////////////////////////////////////////////////////
/*
///////////////////////////////////////////////////////
// This is the OLD BMI check: (Pre 2004 Jan 12)
///////////////////////////////////////////////////////
function FieldsErrorCheck(&$ErrMsgArray, &$FieldErrArray)
{
// Return 0 if no errors and 1 if there are errors
// Global variables:
global $FirstName, $LastName, $WeightKg, $HeightMt, $EmailAddress;
// OLD!!!! global $FirstName, $LastName, $WeightKg, $HeightMt, $EmailAddress, $HeightError, $WeightError, $EmailErrStr;
// Define the Error Message Array: $ErrMsgArray
$ErrMsgArray = array();
// Define the Field Error Array: $FieldErrArray
$FieldErrArray = array();
// Initialize the flags
$ErrorsPresent = 1;
$NoErrors = 0;
$WeightError = 0;
$FieldErrArray["WeightKg"] = 0;
If (!$WeightKg)
{
$WeightError = 1;
$FieldErrArray["WeightKg"] = 1;
$ErrMsgArray[] = "Please enter WEIGHT.";
}
If (($WeightKg) && ($WeightKg < 2))
{
$WeightError = 1;
$FieldErrArray["WeightKg"] = 1;
$ErrMsgArray[] = "WEIGHT too small.";
}
If (($WeightKg) && ($WeightKg > 400))
{
$WeightError = 1;
$FieldErrArray["WeightKg"] = 1;
$ErrMsgArray[] = "WEIGHT too big.";
}
$HeightError = 0;
If (!$HeightMt)
{
$HeightError = 1;
$FieldErrArray["HeightMt"] = 1;
$ErrMsgArray[] = "Please enter HEIGHT.";
}
If (($HeightMt) && ($HeightMt < .3))
{
$HeightError = 1;
$FieldErrArray["HeightMt"] = 1;
$ErrMsgArray[] = "HEIGHT too small.";
}
If (($HeightMt) && ($HeightMt > 4))
{
$HeightError = 1;
$FieldErrArray["HeightMt"] = 1;
$ErrMsgArray[] = "HEIGHT too big.";
}
If (!$EmailAddress)
{
$ErrMsgArray[] = "Please enter EMAIL ADDRESS.";
$FieldErrArray["EmailAddress"] = 1;
}
$EmailErrStr = ValidateField($EmailAddress, "SingleEmail");
If (($EmailAddress) && (!($EmailErrStr == "OK")))
{
$ErrMsgArray[] = "EMAIL ADDRESS seems incorrect.";
$FieldErrArray["EmailAddress"] = 1;
}
// if (!$FirstName) $ErrMsgArray[] = "No first name entered";
// if (!$LastName) $ErrMsgArray[] = "No last name entered";
// if (!$City) $ErrMsgArray[] = "No city entered";
// if (!$Gender) $ErrMsgArray[] = "Gender not selected";
// if (!$Comments) $ErrMsgArray[] = "No comment entered";
// How many errors?
$ErrorCount = count($ErrMsgArray);
// If there are errors, then return true, otherwise false
return ($ErrorCount) ? $ErrorsPresent : $NoErrors;
} // End: function FieldsErrorCheck(&$ErrMsgArray)
///////////////////////////////////////////////////////
*/
///////////////////////////////////////////////////////
Function CalcBMI($WeightKg, $HeightMt)
{
// global $WeightKg, $HeightMt;
// returns the body mass index (BMI)
// if ($HeightMt > 3)
// {
// // echo "That's a huge height! How about something smaller?
";
// }
if ($HeightMt <= 0)
{
// echo "That's a pretty small height! Please input something bigger.
";
$HeightMt = 0.000001;
}
return $WeightKg / ($HeightMt * $HeightMt);
} // End: Function CalcBMI($WeightKg, $HeightMt)
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
function InterpretBMI($BMI)
{
global $WeightRanges, $BMI;
// Underweight:
if ($BMI <= $WeightRanges["UnderweightMax"])
{
echo("\n");
echo("".$BMI." - Underweight.
");
}
// Normal:
if ($BMI > $WeightRanges["UnderweightMax"] && $BMI <= $WeightRanges["NormalMax"])
{
echo("\n");
echo("".$BMI." - Normal weight.
");
}
// Overweight:
if ($BMI > $WeightRanges["NormalMax"] && $BMI <= $WeightRanges["OverweightMax"])
{
echo("\n");
echo("".$BMI." - Overweight.
");
}
// Obese:
if ($BMI > $WeightRanges["OverweightMax"])
{
echo("\n");
echo("".$BMI." - Obese.
");
}
Echo("
\n");
return;
} // End: function InterpretBMI($BMI)
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
Function ShowResults()
{
global $WeightLb, $HeightFt, $HeightIn, $WeightKg, $HeightMt;
// Needed to get rid of Undefined variable error in PHP5:
// 2009 Apr 20 DB:
$BMI=0.0;
echo "