acipinarli Posted June 12, 2009 Share Posted June 12, 2009 Arkadaşlar resimdeki gibi bir form düzenledim ders kaydı yaptırıyorum tüm hatalara karşı önlemimi almaya çalışıyorum ve sizden şu konuda yardım istiyorum. Sınıf mevcudu girildiğinde girilen değer sayı olmazsa hata vermesini istiyorum. şu aşamada sınıf mevcudu sayı değilde yazı girilirse sınıf mevcudu vertabanına 0 olarak kaydediliyor. bunun önüne geçmek için yardımınıza ihtiyacım var teşekkürler. Not : Java script koduda olabilir php koduda olabilir. Link to comment Share on other sites More sharing options...
ibodigital Posted June 12, 2009 Share Posted June 12, 2009 Arkadaşım en kolay yöntem sınıf mevcudunun 0 ile 100 arasında olup olmadığını kontrol edersin. 100 yerine artık bir sınıfın mevcudu maksimum kaç olabilirse onu yazarsın. Eğer kontrol başarısız olursa da hata mesajı yazmasını sağlarsın. Link to comment Share on other sites More sharing options...
acipinarli Posted June 12, 2009 Author Share Posted June 12, 2009 Arkadaşım en kolay yöntem sınıf mevcudunun 0 ile 100 arasında olup olmadığını kontrol edersin. 100 yerine artık bir sınıfın mevcudu maksimum kaç olabilirse onu yazarsın. Eğer kontrol başarısız olursa da hata mesajı yazmasını sağlarsın. evet mantıklı deneyeyim bakalım. teşekkürler. Link to comment Share on other sites More sharing options...
acipinarli Posted June 12, 2009 Author Share Posted June 12, 2009 maalesef olmadı. orayı algılamıyor. bir türlü. kodu aşağıdaki gibi yazdım birde siz kontrol edin isterseniz. if (!$HTTP_POST_VARS['sinif_mevcudu']==NULL) //sınıf mevcudu girildi mi? $sinif_mevcudu = $HTTP_POST_VARS["sinif_mevcudu"]; else if (!(($sinif_mevcudu >0) and ($sinif_mevcudu <100))) { $mesaj_sinif_mevcudu="Sınıf mevcudu bir sayı olmalıdır."; } else { $sinif_mevcudu=""; $hata=1; $mesaj_sinif_mevcudu = "Sınıf mevcudu girilmedi."; } kırmızı ile işaretlidiğim kısım kaldırılırsa sorun yok çalışıyor. böylede çalışıyor tabi sınıf mevcudu sayı olursa ama olmazsa "Sınıf mevcudu bir sayı olmalıdır." mesajını vermiyor. mysql zaten kaydı reddediyor. İşte ben sorunun mevcuttan kaynaklandığı mesajını vermek istiyorum. Link to comment Share on other sites More sharing options...
YaSVeLi Posted June 12, 2009 Share Posted June 12, 2009 <?php if(!$HTTP_POST_VARS[a]){ ?> <form action="" method="post"> <input type="text" name="a"> <input type="submit" value="gir"> </form> <?php }else{ if($HTTP_POST_VARS[a]>0 && $HTTP_POST_VARS[a]<10) echo "10"; else echo "yokkkk"; echo "<br>".$HTTP_POST_VARS[a]."<br>"; } ?> Link to comment Share on other sites More sharing options...
YaSVeLi Posted June 12, 2009 Share Posted June 12, 2009 <?phpif(!$HTTP_POST_VARS[a]){ ?> <form action="" method="post"> <input type="text" name="a"> <input type="submit" value="gir"> </form> <?php }else{ if($HTTP_POST_VARS[a]>0 && $HTTP_POST_VARS[a]<10) echo "10"; else echo "yokkkk"; echo "<br>".$HTTP_POST_VARS[a]."<br>"; } ?> 0-10 arası sayı girincee ekrana 10 degilsee yokkk yazar işini görür gibimee geliyor ! Link to comment Share on other sites More sharing options...
acipinarli Posted June 12, 2009 Author Share Posted June 12, 2009 çok teşekkürler. becerdim sonunda sayende. sanırım ben if kısmında hata yaptım senin kodu modifiye ettim çalıştı teşekkürler tekrar. Link to comment Share on other sites More sharing options...
YaSVeLi Posted June 12, 2009 Share Posted June 12, 2009 yardımcı olabildiysem ne mutlu ! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.