$to = "mail@mail.com";
$subject = "form";
$name = $_POST['ad'] ;
$name = mb_convert_encoding($name ,"iso-8859-9","utf-8");
$email = $_POST['mail'] ;
$message = $_POST['mesaj'] ;
$message = mb_convert_encoding($message ,"iso-8859-9","utf-8");
$pass= $_POST['guvenlik'];
$headers = "From: ". $name . " <" . $email . ">\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-9\r\n";
$mesa = "Ad Soyad: $name \n Mail Adresi: $email \n Mesaj: $message \n Ip No : $ip \n Tarih : [$tarih] Saat : [$saat]";
if( empty($name) || empty($mail) || empty($message) ) {
echo "Lütfen Gerekli Alanları Doldurunuz!";
}
elseif ($pass=="")
{echo "Lütfen Parolayı Giriniz";}
elseif (isset($_POST["guvenlik"])!=$_POST["guvenlik"])
{echo "Parolayı Doğru Giriniz";}
elseif (isset($_POST["guvenlik"])==$_POST["guvenlik"])
$sent = mail($to, $subject, $mesa, $headers);
}
?> Parola Kontrolü
8
●810
- 26-05-2009, 10:50:18Aşağıdaki kodlardan bir türlü parola kontrolünü yapamadım.Yani parola yanlış ve boş girildiği zaman hata uyarısını veriyor ama doğru parolayla girilince tekrar hata alıyorum.Bunu nasıl halledebilirim?
- 26-05-2009, 11:19:10bu şekillerde de denedim;Aykut adlı üyeden alıntı: mesajı görüntüle
$to = "mail@mail.com"; $subject = "form"; $name = $_POST['ad'] ; $name = mb_convert_encoding($name ,"iso-8859-9","utf-8"); $email = $_POST['mail'] ; $message = $_POST['mesaj'] ; $message = mb_convert_encoding($message ,"iso-8859-9","utf-8"); $pass= $_POST['guvenlik']; $headers = "From: ". $name . " <" . $email . ">\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-9\r\n"; $mesa = "Ad Soyad: $name \n Mail Adresi: $email \n Mesaj: $message \n Ip No : $ip \n Tarih : [$tarih] Saat : [$saat]"; if( empty($name) || empty($mail) || empty($message) ) { echo "Lütfen Gerekli Alanları Doldurunuz!"; } elseif ($pass=="") {echo "Lütfen Parolayı Giriniz";} elseif (isset($_POST["guvenlik"]) && $_POST["guvenlik"] != $_POST["guvenlik"]) {echo "Parolayı Doğru Giriniz";} elseif (isset($_POST["guvenlik"]) && $_POST["guvenlik"] == $_POST["guvenlik"]) $sent = mail($to, $subject, $mesa, $headers); } ?>$to = "mail@mail.com"; $subject = "form"; $name = $_POST['ad'] ; $name = mb_convert_encoding($name ,"iso-8859-9","utf-8"); $email = $_POST['mail'] ; $message = $_POST['mesaj'] ; $message = mb_convert_encoding($message ,"iso-8859-9","utf-8"); $pass= $_POST['guvenlik']; $headers = "From: ". $name . " <" . $email . ">\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-9\r\n"; $mesa = "Ad Soyad: $name \n Mail Adresi: $email \n Mesaj: $message \n Ip No : $ip \n Tarih : [$tarih] Saat : [$saat]"; if( empty($name) || empty($mail) || empty($message) ) { echo "Lütfen Gerekli Alanları Doldurunuz!"; } elseif ($pass=="") {echo "Lütfen Parolayı Giriniz";} elseif (isset($_POST["guvenlik"]) || $_POST["guvenlik"] != $_POST["guvenlik"]) {echo "Parolayı Doğru Giriniz";} elseif (isset($_POST["guvenlik"]) && $_POST["guvenlik"] == $_POST["guvenlik"]) $sent = mail($to, $subject, $mesa, $headers); } ?>bunun gibi birçok versiyon denedim ama ya birinde kod kontrolü yapmadan gönderdi ya da hiçbirşekilde göndermedi.yazdığınız " $dogruSifre !" yerine ne yazmalıyım onu anlayamadım?çünkü gelen parola sayfa her yenilendiğinde değişen bir parola.
NOT: İlk elseif bölümüne and koyduğumda parolayı kontrol etmeden veriyi gönderiyor ama or koyduğumda parolayı kontrol ediyor ama ikinci şartım olan parola doğru olduğunda da hata veriyor bu seferde. - 26-05-2009, 11:34:03Bir mantıksızlık var, bunlar aynı şeyler aynı degerler zaten .Alıntı
zannedersem resim doğrulama kodu gibi bir şey yaptığınız ama sessiondaki değeri almanız gerek bunun için.
şöyle bir yol izleyebilirsiniz.
.... .. . elseif (isset($_POST['guvenlik'])) { if($_POST['guvenlik']==$session_sifren) { $sent=.... }else{ ... şifre hatalı... } }else{ şifre boş } - 26-05-2009, 11:40:55Üyeliği durdurulduajaxlı birşey yapmıştım 1 seneyi geçmiştir yapalı örnek olması açısından bakabilirsin
ön izleme :
http://www.ankabt.net/labs/saho-login/
kaynak dosyaları :
http://www.ankabt.net/labs/saho-login/index.phps
http://www.ankabt.net/labs/saho-login/islem.phps - 26-05-2009, 11:54:57bunuda denedim ama aynı şey oluyor,yani şifre yanlış yazıldığında tamam hata veriyor ama doğru yazıldığında da hata veriyor.Sessiondaki değerden kastınızuysal_rockci adlı üyeden alıntı: mesajı görüntüle
session_start(); $_SESSION["guvenlik"] = $pass;buysa bunu da denedim olmadı.Biryerde mantıksal bir yanlış yapıyorum büyük ihtimal ama nerde?
en iyisi bütün kodları vereyim;
Güvenlikkodu.php
<?php /*Bismillahirrahmanirrahim*/ //olusturulmus resmi tarayiciya gonderir create_image(); exit(); function create_image() { //md5 ile rastgele sayi uretelim $md5 = md5(rand(0,999)); //32 karakter yerine sadece 5 karakterini aliyoruz $pass = substr($md5, 10, 6); //Session aktar session_start(); $_SESSION["guvenlik"] = $pass; //resmin boyutlarini ayarliyoruz $width = 100; $height = 20; //resim kaynagini olusturuyoruz $image = ImageCreate($width, $height); //Beyaz siyah ve gri renklerini olusturuyoruz $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); $grey = ImageColorAllocate($image, 204, 204, 204); //Zemini siyah yapiyoruz ImageFill($image, 0, 0, $black); //Rastgele sayiyi resmin uzerine yaziyoruz ImageString($image, 3, 30, 3, $pass, $white); //sunucuya resmin turunu belirtiyoruz header("Content-Type: image/jpeg"); //Yeni jpeg formatindaki resmin ciktisini aliyoruz ImageJpeg($image); //Kaynagi temizliyoruz ImageDestroy($image); } ?>mail.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <table width="292" border="0"> <td width="118"> <tr> <td width="45">İsminiz</td> <td width="144"><form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> <input type="text" name="ad" /> * <?PHP if (isset($_POST["ad"]) && $_POST["ad"]=="") echo "Adınızı giriniz"; ?> </td> </tr> <tr> <td>E-mail</td> <td width="164"> <input type="text" name="mail" /> * <?PHP if (isset($_POST["ad"]) && $_POST["ad"]=="") echo "Mail Adresinizi Giriniz"; ?></td> </tr> <tr> <td >Güvenlik Kodu</td> <td ><img src="guvenlik.php" alt="guvenlik" border="0"/></td> </tr> <tr> <td height="40" > Kodu Giriniz</td> <td > <input type="text" name="guvenlik" size="25" ><?PHP if (isset($_POST["guvenlik"]) && $_POST["guvenlik"]=="" ) echo "Parolayı giriniz"; ?></td> <tr> <td>Mesajınız</td> <td> <textarea name="mesaj" id="textarea" cols="20" rows="5"></textarea> </td> </tr> <tr> <td colspan="2"><input type="submit" value="Gönder" /> <input type="reset" value="Temizle" /></form></td> </tr> </table> </body> </html> <?php if(extract($_POST)) { $tarih = date ("d.m.y"); // Tarihi aliyoruz. $saat = date ("h:i:s"); // Saati aliyoruz $ip =$_SERVER['REMOTE_ADDR']; //Ziyaretçinin ip numarasini aliyoruz. $to = "mail@mail.com"; $subject = " Mail Formu"; $name = $_POST['ad'] ; $name = mb_convert_encoding($name ,"iso-8859-9","utf-8"); $email = $_POST['mail'] ; $message = $_POST['mesaj'] ; $message = mb_convert_encoding($message ,"iso-8859-9","utf-8"); $pass= $_POST['guvenlik']; $headers = "From: ". $name . " <" . $email . ">\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-9\r\n"; $mesa = "Ad Soyad: $name \n Mail Adresi: $email \n Mesaj: $message \n Ip No : $ip \n Tarih : [$tarih] Saat : [$saat]"; if( empty($name) || empty($mail) || empty($message) ) { echo "Lütfen Gerekli Alanları Doldurunuz!"; } elseif ($pass=="") {echo "Lütfen Parolayı Giriniz";} elseif (isset($_POST["guvenlik"]) || $_POST["guvenlik"] != $pass) {echo "Parolayı Doğru Giriniz";} elseif (isset($_POST["guvenlik"]) && $_POST["guvenlik"] == $pass) $sent = mail($to, $subject, $mesa, $headers); } ?> - 26-05-2009, 12:15:26Hocam sen session dan almıyosunki $pass ın sessiondan alınması gerek
edit böle yap yani
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <table width="292" border="0"> <td width="118"> <tr> <td width="45">İsminiz</td> <td width="144"><form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> <input type="text" name="ad" /> * <?PHP if (isset($_POST["ad"]) && $_POST["ad"]=="") echo "Adınızı giriniz"; ?> </td> </tr> <tr> <td>E-mail</td> <td width="164"> <input type="text" name="mail" /> * <?PHP if (isset($_POST["ad"]) && $_POST["ad"]=="") echo "Mail Adresinizi Giriniz"; ?></td> </tr> <tr> <td >Güvenlik Kodu</td> <td ><img src="guvenlik.php" alt="guvenlik" border="0"/></td> </tr> <tr> <td height="40" > Kodu Giriniz</td> <td > <input type="text" name="guvenlik" size="25" ><?PHP if (isset($_POST["guvenlik"]) && $_POST["guvenlik"]=="" ) echo "Parolayı giriniz"; ?></td> <tr> <td>Mesajınız</td> <td> <textarea name="mesaj" id="textarea" cols="20" rows="5"></textarea> </td> </tr> <tr> <td colspan="2"><input type="submit" value="Gönder" /> <input type="reset" value="Temizle" /></form></td> </tr> </table> </body> </html> <?php if(extract($_POST)) { $tarih = date ("d.m.y"); // Tarihi aliyoruz. $saat = date ("h:i:s"); // Saati aliyoruz $ip =$_SERVER['REMOTE_ADDR']; //Ziyaretçinin ip numarasini aliyoruz. $to = "mail@mail.com"; $subject = " Mail Formu"; $name = $_POST['ad'] ; $name = mb_convert_encoding($name ,"iso-8859-9","utf-8"); $email = $_POST['mail'] ; $message = $_POST['mesaj'] ; $message = mb_convert_encoding($message ,"iso-8859-9","utf-8"); session_start(); $pass= $_SESSION["guvenlik"]; $headers = "From: ". $name . " <" . $email . ">\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-9\r\n"; $mesa = "Ad Soyad: $name \n Mail Adresi: $email \n Mesaj: $message \n Ip No : $ip \n Tarih : [$tarih] Saat : [$saat]"; if( empty($name) || empty($mail) || empty($message) ) { echo "Lütfen Gerekli Alanları Doldurunuz!"; } elseif ($pass=="") {echo "Lütfen Parolayı Giriniz";} elseif (isset($_POST["guvenlik"]) || $_POST["guvenlik"] != $pass) {echo "Parolayı Doğru Giriniz";} elseif (isset($_POST["guvenlik"]) && $_POST["guvenlik"] == $pass) $sent = mail($to, $subject, $mesa, $headers); } ?>