• 17-10-2009, 17:54:01
    #1
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Merhaba arkadaşlar ben formda resimli güvenlik kodu kullanmak istiyorum. Resim üzerine sayı ve rakamları yazdırıyorum. Ancak formda güvenli kodu bölümüne girilen kod ile resimdeki kodun uyuşup uyuşmadığını nasıl kontrol edicem bi türlü yapamadım..Kodlar aşağıda yardımcı olursanız sevinirim...

    guvenlik.php
    <?php
    function olustur () {
     $sifre = substr(md5(rand(0,999999999999)),-6);
     if ($sifre) {
      session_start();
      $_SESSION["guv"] = $sifre;
      $width  = 100;
      $height =  30;
      $resim  = ImageCreate($width,$height);
      $beyaz  = ImageColorAllocate($resim, 255, 255, 255);
      $rand   = ImageColorAllocate($resim, rand(0,255), rand(0,255), rand(0,255));
      ImageFill($resim, 0, 0, $rand);
      ImageString($resim, 5, 24, 7, $_SESSION["guv"], $beyaz);
      ImageLine($resim, 100, 19, 0, 19, $beyaz);
      header("Content,type: image/png");
      ImagePng($resim);
      ImageDestroy($resim);
     }
    }
    olustur();
    ?>
    form.php
    <?php session_start(); ?>
    <form method="POST" action="kontrol.php">
    <img src="guvenlik.php"><br>
    Güvenlik Kodu:
    <label>
    <input type="text" name="kod" id="kod" />
    </label>
    <br>
    <label>
    <input type="submit" name="button" id="button" value="Gonder" />
    </label>
    </FORM>
  • 17-10-2009, 18:00:38
    #2
    Kimlik doğrulama veya yönetimden onay bekliyor.
    <?php
    session_start(); 
    if (empty($_POST)) {
    ?>
    <form method="POST" action="">
    <img src="guvenlik.php"><br>
    Güvenlik Kodu:
    <label>
    <input type="text" name="kod" id="kod" />
    </label>
    <br>
    <label>
    <input type="submit" name="button" id="button" value="Gonder" />
    </label>
    </FORM>
    <?php 
    } else {
    if ($_SESSION["guv"] == $_POST['kod']) {
    //kod doÄŸrusa
    } else {
    //kod yanlıssa
    }
    }
    ?>
  • 17-10-2009, 18:43:04
    #3
    çok saol hocam oldu.. eline sağlıkk
  • 20-10-2009, 15:03:44
    #4
    tÅŸk saolun