codeboy89 Posted November 28, 2009 Share Posted November 28, 2009 I am very new and learning, could any give me a snippet that will simply submit text from an input form for an post it to a page. Link to comment https://forums.phpfreaks.com/topic/183235-help-me-with-basic-script/ Share on other sites More sharing options...
$Three3 Posted November 28, 2009 Share Posted November 28, 2009 Here is the html form you need: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>BMI Calculator</title> </head> <body> <form action="bmi.php" method="post"> Enter Your Height (Inches) <input name="height" type="text" size="7" /> <br /> <br /> Enter Your Weight (Pounds) <input name="weight" type="text" size="7" /> <br /> <br /> <input name="submit" type="submit" value="Submit" /> </form> </body> </html> and here is the php code you need: <?php $height = $_POST['height'] ; $weight = $_POST['weight'] ; ?> <?php $bmih = $height * $height ; $bmiw = $weight/$bmih ; $bmiw *= 703 ; echo "Your BMI (Body Mass Index) is " . number_format($bmiw , 2 , '.', ',') . "." ; echo "<br />" ; echo "<ul>" ; echo "<li>Normal weight = 18.5-24.9</li>" ; echo "<li>Overweight = 25-29.9</li>" ; echo "<li>Obesity = BMI of 30 or greater</li>" ; echo "</ul>" ; ?> You should name the html form "bmi.html" and the php form should be named "bmi.php". Just copy and paste these into a file and save them with the names above. The script will calculate your BMI (Body Mass Index). It uses really basic PHP operators and functions. Hope this helps you. Link to comment https://forums.phpfreaks.com/topic/183235-help-me-with-basic-script/#findComment-967082 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.