Php 'de Switch Case Kodları Ders 10
######İndex.Php Kodları############
<form action="kontrol.php" method="POST">
<table cellpadding="5" cellspacing="5">
<tr>
<td>Ad Soyad: </td>
<td><input type="text" name="adsoyad" /></td>
</tr>
<tr>
<td>Sehir : </td>
<td><select name="sehir">
<option value="a">İstanbul</option>
<option value="b">Bursa</option>
<option value="c">Ankara</option>
<option value="d">Adana</option>
<option value="e">İzmir</option></select></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Gönder" /></td>
</tr>
<table>
</form>
##################Kontrol.php Kodları ##############3
<?php
$adsoyad = $_POST["adsoyad"] ;
$sehir = $_POST["sehir"] ;
echo "Adınız ve Soyadınız : ".$adsoyad ;
/*if ($sehir == "a") {
echo "Seçtiniz Şehir İstanbul" ;
} elseif($sehir =="b") {
echo "Seçtiniz sehir Bursa" ;
} elseif ($sehir =="c" ) {
echo "Sectiniz sehir Ankaradır" ;
} else {
echo "Farklı Bir Şehir sectiniz" ;
}*/
switch ($sehir) {
case"a" ;
echo "Seçtiniz Şehir İstanbul" ;
break ;
case"b" ;
echo "Seçtiniz sehir Bursa" ;
break ;
case"c" ;
echo "Sectiniz sehir Ankaradır" ;
break ;
default ;
echo " Farklı bir şehir sectiniz" ;
break ;
}
?>
