IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası

IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası (https://www.ircforumlari.net/)
-   PHP (https://www.ircforumlari.net/php/)
-   -   Php'de Güvenlik Kodu Yapmak (https://www.ircforumlari.net/php/976127-phpde-guvenlik-kodu-yapmak.html)

Che 23 Nisan 2022 22:43

Php'de Güvenlik Kodu Yapmak
 
Php ile kodladığınız sistemlerde üye girişi, sipariş forumları ve yorumlar gibi bölümlerde saldırıları önlemek için aşağıdaki Php güvenlik kodu yapımı örneğini kullanarak, Php güvenlik kodu oluşturabilirsiniz.



giris.php

Kod:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>Php Güvenlik Kodu Örneği</title>
</head>
<body>
<form action="kontrol.php" method="POST">
<table width="300" align="center">
<tbody>
<tr><td>Kullanıcı Adı:</td><td><input type="text" name="kullanici" size="15" /></td></tr>
<tr><td>Şifre:</td><td><input type="password" name="sifre" size="15" /></td></tr>
<tr><td>Güvenlik Kodu:</td></tr>
<tr>
<td><img alt="Güvenlik Kodu" src="guvenlik.php" /></td>
<td><input type="text" name="guvenlik" size="15" /></td>
</tr>
<tr><td colspan="2"><input type="submit" value="Gönder" /></td></tr>
</tbody>
</table>
</form>
</body>
</html>



guvenlik.php

Kod:

<?php
session_start();
$sifre = substr(md5(rand(0,999999999999)), -6); // Güvenlik kodu uzunluğu
if($sifre){
$_SESSION["gkodu"] = $sifre;
$width = 100; // Güvenlik kodu resmi genişliği
$height = 30; // Güvenlik kodu resmi yüksekliği
$resim = ImageCreate($width, $height);
$arka = ImageColorAllocate($resim, 255, 255, 255); // Güvenli kodu metin rengi
$rand = ImageColorAllocate($resim, rand(0,255), rand(0,255), rand(0,255));
ImageFill($resim, 0, 0, $rand);
ImageString($resim, 5, 24, 7, $_SESSION["gkodu"], $arka);
ImageLine($resim, 0, 19, 0, 19, $arka);
header("Content,type:image/png");
ImagePng($resim);
ImageDestroy($resim);
}
?>



kontrol.php

Kod:

<?php
session_start();
header('Content-type: text/html; charset=utf8');
if( empty($_POST["guvenlik"]) && empty($_SESSION["gkodu"]) && !$_SESSION["gkodu"] ){
echo "<a href='index.php'>Lütfen Giriş yapın</a>";
} else {
if( $_POST["guvenlik"] == $_SESSION["gkodu"] ){
echo "Güvenlik kodu doğru girildi.";
} else {
echo "Güvenlik kodu hatalı girildi.";
}
}
?>



[Üye Olmadan Linkleri Göremezsiniz. Üye Olmak için TIKLAYIN...]


Tüm Zamanlar GMT +3 Olarak Ayarlanmış. Şuanki Zaman: 20:41.

Powered by vBulletin® Version 3.8.8 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO
Copyright ©2004 - 2024 IRCForumlari.Net