İletişim formu güvenlik kodu
1
●87
- Kabul Edilen Cevap
- 1 Beğeni
-
- 28-06-2021, 10:18:31Bu cevap, moderatörlerimiz tarafından kabul edilebilir bir cevap olarak işaretlendi.Kimlik doğrulama veya yönetimden onay bekliyor.Merhaba php SESSION ile iletişim formunuza basit bir güvenlik kodu ekleyebilirsiniz.
Örnek;

index.php;
<script src="http://code.jquery.com/jquery-latest.min.js"></script> <script language="javascript"> function ChangeCode(){ var NewSecurity= "<img src='security.php?rnd="+Math.random()+"' alt='guvenlik' style='border: 1px solid #999999;' />"; $("#security").html(NewSecurity); return false; } </script> <form action="kontrol.php" method="post"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <th style="color: #b62463; padding-bottom: 20px; text-align:left;" colspan="4">Güvenlik Doğrulaması</th> </tr> <tr> <th>Güvenlik : </th> <th></th> <td> <div id="security"><img src="security.php" alt="guvenlik" style="border: 1px solid #999999;"></div> </td> <td><a href="javascript:;" onclick="ChangeCode();"><img src="refresh.png" /></a></td> </tr> <tr> <th></th> <th></th> <td><input type="text" name="security"/></td> <td>(Resimdeki kodu giriniz.)</td> </tr> <tr> <th></th> <th></th> <td><input type="submit" value="Gönder"></td> <td></input></td> </tr> </table> </form> </html>security.php;
<?php function olustur () { $sifre = substr(md5(rand(0,999999999999)),-5); if ($sifre) { session_start(); $_SESSION["koruma"] = $sifre; $width = 99; $height = 34; $resim = @imagecreate ($width,$height); $siyah = ImageColorAllocate($resim, 0, 0, 0); $kirmizi = ImageColorAllocate($resim, 182, 36, 99); $beyaz = ImageColorAllocate($resim, 255, 255, 255); ImageFill($resim, 0, 0, $beyaz); $font = 'font/arial.ttf'; imagettftext($resim, 20, 10, 10, 28, $siyah, $font, $sifre[0]); imagettftext($resim, 20, 0, 25, 28, $kirmizi, $font, $sifre[1]); imagettftext($resim, 20, -10, 40, 28, $siyah, $font, $sifre[2]); imagettftext($resim, 20, 0, 55, 28, $kirmizi, $font, $sifre[3]); imagettftext($resim, 20, 0, 70, 28, $siyah, $font, $sifre[4]); header("Content-type: image/png"); ImagePng($resim); ImageDestroy($resim); } } olustur(); ?>kontrol.php;
<?php session_start(); $girilen_kod = trim(strip_tags($_POST['security'])); $guvenlik_kodu = trim(strip_tags($_SESSION['koruma'])); if($girilen_kod != $guvenlik_kodu) { echo 'Güvenlik Kodu Yanlış'; } else { echo 'Güvenlik Kodu Doğru'; } ?>Virus Total: https://www.virustotal.com/gui/file/...ef94/detection
Indirmek için Tıklayın
