Minggu, 05 Oktober 2014

basic php persegi

php basic calculate the area and perimeter of a square using a simple formula
which is the input value



<?php
@$nilai1 = $_POST['nilai1'];
?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <form action="#" method="POST">
            <table>
                <h1>Menentukan luas dan keliling persegi</h1>
                <tr>
                    <td>Masukkan sisi</td>
                    <td>:</td>
                    <td><input type="text" name="nilai1" value="<?php echo $nilai1; ?>"/></td>
                </tr>
                <tr>
                        <td></td>
                        <td></td>
                        <td><input type="submit" name="proses" value="proses"/></td>
                    </tr>
                </table>
            </form>
        </body>
    </html>
    <?php
      $luas=$nilai1*$nilai1;
      echo"luas persegi adalah <b>$luas</b><br>";
      $keliling=4* $nilai1;
      echo"keliling persegi adalah <b>$keliling</b>";

    ?>

Tidak ada komentar:

Posting Komentar