İNTERNET PROGRAMCILIĞI GRAFİK İŞLEMLERİ İLE GÜVENLİK KODU OLUŞTURMA
Uygulama 1: guvenlik_kodu.php ile oluşturulan grafiksel güvenlik kodunun guvenlik_form.php sayfasında gösterilmesi;
guvenlik_form.php
<html>
<body>
<form action=”” method=”post”>
<table width=”666″ border=”2″ cellspacing=”2″ cellpadding=”1″>
<tr>
<th width=”301″ scope=”col”>güvenlik kodu
<label for=”t1″></label>
<input type=”text” name=”t1″ id=”t1″ /></th>
<th width=”347″ scope=”col”><img src=”guvenlik_kodu.php” width=”100″ height=”50″ /></th>
</tr>
<tr>
<td colspan=”2″>
<div align=”center”>
<input type=”submit” name=”b1″ id=”b1″ value=”gönder” />
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
guvenlik_kodu.php
<?php
//Sayfanın grafik olduğunu tarayıcıya bildiriyoruz.
header (“Content-type: image/png”);
//resimi oluşturuyoruz
$resim = imagecreate(100, 50);
//kullanacağımız renkleri oluşturuyoruz
$mavi = imagecolorallocate($resim, 0, 0, 255);
$beyaz = imagecolorallocate($resim, 255,255,255); //resmin uzerine yazacağımız kodu rastgele oluşturuyoruz
$GuvenlikKodu=rand(10000,99999);
//rastgele değerimizi resmin üzerine yazıyoruz
imagestring($resim,9,30,20,$GuvenlikKodu,$beyaz);
//resme çizgi atarak kırılmasını zorlaştırıyoruz
imageline($resim,0,25,100,25,$beyaz);
imageline($resim,0,35,100,35,$beyaz);
//resmi oluşturuyoruz ve tarayıcıda görüntülüyoruz.
imagepng($resim);
//kaynağımızı temizliyoruz
imagedestroy($resim);
?>
