PHP ile bir dört işlem makinesi geliştirdim.

Ve kodlarımız şöyle:

index.php

HTML:
  1. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  2.  
  3. <style type="text/css"> <!-- .style13 {font-size: 13px; font-family: Verdana, Arial, Helvetica, sans-serif; } .style16 {font-family: Georgia, "Times New Roman", Times, serif; font-weight: bold; font-size: 24px;} .style17 {  font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 12px; } --> </style>
  4. <p class="style16">Hesap Makinası</p>
  5.  
  6. <form id="form1" name="form1" method="post" action="islem.php">
  7. <table border="0" width="250">
  8. <td colspan="3"><span class="style13">
  9. <label>1. Sayı :</label>
  10. <input name="sayi1" id="sayi1" type="text" /> </span></td>
  11. </tr>
  12. <td colspan="3"><span class="style13">
  13. <label>2. Sayı :</label>
  14. <input name="sayi2" id="sayi2" type="text" /> </span></td>
  15. </tr>
  16. <td colspan="3"><span class="style13">
  17. <label>İşlem türü:</label>
  18. <select name="islemturu">           <option value="islemsec">Lütfen bir işlem seçin</option>           <option value="topla">Toplama</option>           <option value="carp">Çarpma</option>           <option value="cikar">Çıkarma</option>           <option value="bol">Bölme</option>         </select> </span></td>
  19. </tr>
  20. <td width="47">&nbsp;</td>
  21. <td width="91"><input name="Submit" value="İşlemi uygula" type="submit" /></td>
  22. <td width="98">&nbsp;</td>
  23. </tr>
  24. </table>
  25. </form>

islem.php

PHP:
  1. $toplam = ($sayi1 + $sayi2);
  2. $carpim = ($sayi1 * $sayi2);
  3. $fark = ($sayi1 - $sayi2);
  4. $bolum = ($sayi1 / $sayi2);
  5. switch($islemturu)
  6. {
  7. case "topla" :
  8. echo "Iste sonuç: <strong>$toplam</strong>. Geri dönmek için <font color="red" face="verdana"><a href="javascript:history.go(-1)">tiklayin...</a></font>";
  9. break;
  10. case "carp" :
  11. echo "Iste sonuç: <strong>$carpim</strong>. Geri dönmek için <font color="red" face="verdana"><a href="javascript:history.go(-1)">tiklayin...</a></font>";
  12. break;
  13. case "cikar" :
  14. echo "Iste sonuç: <strong>$fark</strong>. Geri dönmek için <font color="red" face="verdana"><a href="javascript:history.go(-1)">tiklayin...</a></font>";
  15. break;
  16. case "bol" :
  17. echo "Iste sonuç: <strong>$bolum</strong>. Geri dönmek için <font color="red" face="verdana"><a href="javascript:history.go(-1)">tiklayin...</a></font>";
  18. break;
  19. case "islemsec" :
  20. echo "<font color="red" face="verdana"><a href="javascript:history.go(-1)">Lütfen geri dönüp bir islem seçin.</a></font>";
  21. break;
  22. }
  23. ?&gt;