Rabu, 08 Maret 2017

Menghitung Luas Segitiga Menggunakan PHP Dan HTML

File yang pertama untuk index.html dapat kita tuliskan seperti dibawah ini :
 <html>
 <head>
  <title>Luas Segitiga V0.1</title>
 </head>
  <body>
   <form action="rmssgtg.php" method="post">
   <table width="434" height="86" border="2" bordercolor="#FF0000">
    <tr>
     <td align="center" valign="middle"><table width="416" border="0">
      <tr>
       <td height="43" colspan="4" align="center" bgcolor="#D0E382"> 
       <span class="style2"><h2><u><i>Luas Segitiga PHP V0.1</u></i></h2></span></td>
      </tr>
       <tr>
        <td height="41" align="center">&nbsp;</td>
       </tr>
    <pre>
     <tr>
      <td width="117" align="center">
        Alas:  <input name="alas" type="text" id="nilaiA" size="20" value=""/>
      </td>
      <td width="117" align="center">
        Tinggi:  <input name="tinggi1" type="text" id="nilaiB" size="20" value=""/>
      </td>      
     </tr>
    </pre>
    <pre>
   <tr>
    <td height="43" colspan="4" align="center">
     <input type="submit" value="Hitung" />
     <input type="reset" value="Hapus" />  
    </td>
   </tr>
  </pre>
       </table>
     </td>
    </tr>
   </table>
   </form>
  </body>
</html>


Dan untuk file yang kedua yang opodab beri nama rmssgtg.php, dapat opodab tuliskan seperti dibawah ini:
 <html>
 <head>
  <title>Luas Segitiga V0.1</title>
 </head>
  <body>
   
   <table width="434" height="86" border="2" bordercolor="#FF0000">
    <tr>
     <td align="center" valign="middle"><table width="416" border="0">
      <tr>
       <td height="43" colspan="4" align="center" bgcolor="#D0E382"> 
       <span class="style2"><h2><i>Luas Segitiga Dengan PHP V0.1</h2></i></span></td>
      </tr>
       <tr>
        <td height="41" align="center">&nbsp;</td>
       </tr>

 <tr>
  <pre>
   <tr>
    <td height="43" colspan="4" align="center">
<?php
 $nilaiA = $_POST['alas'];
 $nilaiB = $_POST['tinggi1'];
 $luas = undefined$nilaiA * $nilaiB)/2;
  
 
   echo "<strong><U> Dengan Alas : $nilaiA, </u><br><br>";
   echo "<strong><U> Dan Tinggi : $nilaiB, maka:</strong></u><br><br>";
   echo "Luas Segitiga : $luas ";
   
?>    
    </td>
   </tr>
  </pre>
  <pre><form action="luas.html" method="post">
   <tr>
    <td height="43" colspan="4" align="center">
     <input type="submit" value="Back" />
    </td>
   </tr></form>
  </pre>
 </tr>
    
       </table>
     </td>
    </tr>
   </table>
   
  </body>
</html>

0 komentar:

Posting Komentar

 

Education's Template by Ipietoon Cute Blog Design