SeckiN | 02 Kasım 2014 16:28 | PHP – Dikdörtgenin Alanının ve Çevresinin Hesaplama Kullanıcıdan alınan 2 sayı ve radio butonda işaretlemiş olduğu alan hesaplama yada çevre hesaplama bilgisi post metodu ile php dosyasına gönderiliyor daha sonra bu işlemin sonucu ekrana yazdırılıyor. hesaplama.html Kod:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
</head>
<body>
<form action="hesaplama.php" method="post" name="form">
<label>Sayı1</label> <input type="text" name="sayi1" id="sayi1" /><br />
<label>Sayı2</label> <input type="text" name="sayi2" id="sayi2" /><br />
<label>Dikdörtgen Alan</label> <input type="radio" value="alan" name="dikdortgen" id="alan" />
<label>Dikdörtgen Çevre</label> <input type="radio" value="cevre" name="dikdortgen" id="cevre" /><br />
<input type="submit" name="hesapla" value="Hesapla" />
</form>
</body>
</html> hesaplama.php
(PHP kodları yazının devamındadır.) Kod:
<?php
$sayi1=$_POST["sayi1"];
$sayi2=$_POST["sayi2"];
$secim=$_POST["dikdortgen"];
switch($secim){
case "alan":
$sonuc=$sayi1*$sayi2;
echo "Dikdörtgenin Alanı :".$sonuc;break;
case "cevre":
$sonuc=($sayi1+$sayi2)*2;
echo "Dikdörgenin Çevresi :".$sonuc;break;
default: echo"hesaplanmamış";}
?> Alıntı |