- <!DOCTYPE html>
- <html>
- <body>
- <?php
- echo '<h1>個人信息</h1>';
- $name=$_POST["name"];
- $height=$_POST["height"];
- $weight=$_POST["weight"];
- echo '<p>姓名:'.$name.'</p>';
- echo '<p>身高:'.$height.'</p>';
- echo '<p>體重:'.$weight.'</p>';
- echo '<p>年齡:'.$_POST["age"].'</p>';
- echo '<h1>BMI</h1>';
- $BMI= $weight / $height / $height *10000;
- echo '<p>BMI = '.$BMI."</p>";
- ?>
- </body>
- </html>
複製代碼- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- </head>
- <body>
- <h1>請輸入已下訊息</h1>
- <form method="post" action="practice2.php">
- <label>姓名: </label>
- <input type="name" name="name"><br>
- <label>身高(cm): </label>
- <input type="number" name="height"><br>
- <label>體重(kg): </label>
- <input type="number" name="weight"><br>
- <label>年齡: </label>
- <input type="number" name="age"><br>
- <input type="submit">
- </form>
- </body>
- </html>
複製代碼 |