Selasa, 07 Mei 2019

Program Kalkulator Sederhana dengan PHP (Revisi) part 2

Code program untuk jumlah.php

  <?php
  echo "<b>Hitung jumlah</b>";
  echo "<br>";
 
  //$x=3;
  //$y=5;
  //$z=$x+$y;
 
  echo "<form method='POST' action='jumlah.php'>";
  echo "<input type='text' name='x' placeholder='masukkan nilai x'></input>";
  echo "<br>";
  echo "<input type='text' name='y' placeholder='masukkan nilai y'></input>";
  echo "<br>";
  echo "<input type='submit' name='submit' value='hitung'></input>";
  echo "<input type='reset' name='reset' value='reset'></input>";
  echo "</form>";
  echo "<br>";
  
 if(isset($_POST['submit']))
{
  $x=$_POST['x'];
  $y=$_POST['y'];
  $z=$x+$y;
  echo "nilai x adalah:".$x;
  echo "<br>";
  echo "nilai y adalah:".$y;
  echo "<br>";
  echo "<b>hasil jumlah x+y adalah ".$z."</b>";
} 
  
?>
Gambar dibawah menampilkan hasil proses jumlahnya setelah klik hitung

0 komentar:

Posting Komentar