Minggu, 05 Oktober 2014

basic php persegi panjang

for those of you who want to learn php algorithm starting compulsory
basic as learning to use a simple mathematical formula
I am here as an example of using the formula to calculate the area and perimeter

of the rectangle, and its results you just input the length and width of the result area and perimeter of the rectangle will appear




<?php
@$panjang = $_POST['panjang'];
@$lebar = $_POST['lebar'];
?>
<!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 panjang</h1>
                <tr>
                    <td>Masukkan panjang</td>
                    <td>:</td>
                    <td><input type="text" name="panjang" value="<?php echo $panjang; ?>"/></td>
                </tr>
                <tr>
                    <td>Masukkan lebar</td>
                    <td>:</td>
                    <td><input type="text" name="lebar" value="<?php echo $lebar; ?>"/></td>
                </tr>
                <tr>
                        <td></td>
                        <td></td>
                        <td><input type="submit" name="proses" value="proses"/></td>
                    </tr>
                </table>
            </form>
        </body>
    </html>
    <?php
      $luas=$panjang*$lebar;
      echo"luas persegi adalah <b>$luas</b><br>";
      $keliling=2* ($panjang+$lebar);
      echo"keliling persegi adalah <b>$keliling</b>";

    ?>

Tidak ada komentar:

Posting Komentar