• 05-01-2009, 17:05:11
    #1
    Merhaba arkadaşlar;

    Siteme eklemiş olduğum formdaki bilgileri submit kontrolü ile başka sayfaya yönlendireceğim ve onu db'e kayıt yaptıracağım.

    Kullandığım kodlar;

    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_reloadPage(init) {  //reloads the window if Nav4 resized
      if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
        document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
      else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
    }
    MM_reloadPage(true);
    
    function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,center,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v1.1
      var autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;  
      if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
      if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
      if (center && center != "" && popWidth > 0 && popHeight > 0) {
        if (document.all || document.layers || document.getElementById) {
          w = screen.availWidth; h = screen.availHeight;}
        var leftPos = (w-popWidth)/2, topPos = (h-popHeight)/2;
        features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;}
      if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
      popupWindow = window.open(theURL,winName,features);
      if (popupWindow.opener == null) popupWindow.opener = self;    
      if (document.all || document.layers || document.getElementById) {
        if (borderless && borderless != "") {popupWindow.resizeTo(popWidth,popHeight); popupWindow.moveTo(leftPos, topPos);}
        if (alwaysOnTop && alwaysOnTop != "") {
        	ontopIntervalHandle = popupWindow.setInterval("window.opener.popupWindow.focus();", 50);
        	popupWindow.document.body.onload = function() {popupWindow.setInterval("window.opener.popupWindow.focus();", 50);}; }
        if (autoCloseTime && autoCloseTime > 0) {
        	popupWindow.document.body.onbeforeunload = function() {
      			if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
        		window.onbeforeunload = null;	}  
       		autoCloseTimeoutHandle = window.setTimeout("popupWindow.close()", autoCloseTime * 1000); }
      	window.onbeforeunload = function() {popupWindow.close();}; }   
      document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
    }
    
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }
    
    function MM_validateForm() { //v4.0
      var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
      for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
        if (val) { nm=val.name; if ((val=val.value)!="") {
          if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
            if (p<1 || p==(val.length-1)) errors+='- '+nm+' geçerli bir email adresi olmalı.\n';
          } else if (test!='R') { num = parseFloat(val);
            if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
            if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
              min=test.substring(8,p); max=test.substring(p+1);
              if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
        } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' gerekli.\n'; }
      } if (errors) alert('Şu hatalar var:\n'+errors);
      document.MM_returnValue = (errors == '');
    }
    //-->
    </script>
    <form id="form1" name="form1" method="post" action="http://www.xxx.com/iletisim.php">
                 <table width="96%"  border="0">
                   <tr>
                     <td width="27%" nowrap="nowrap" class="online_izle style7 style18"><div align="right" class="style27">Ad Soyad </div></td>
                     <td width="3%" class="style25 style18 online_izle style28">:</td>
                     <td width="70%" class="style13"><input name="Ad" type="text" id="Ad" size="35" /></td>
                   </tr>
                   <tr>
                     <td nowrap="nowrap" class="online_izle style7 style18"><div align="right" class="style27">E-posta</div></td>
                     <td class="style25 style18 online_izle style28">:</td>
                     <td class="style13"><input name="Eposta" type="text" id="Eposta" size="35" /></td>
                   </tr>
                   <tr>
                     <td nowrap="nowrap" class="online_izle style7 style18"><div align="right" class="style27">Firmanız</div></td>
                     <td class="style25 style18 online_izle style28">:</td>
                     <td class="style13"><input name="Firma" type="text" id="Firma" size="35" /></td>
                   </tr>
                   <tr>
                     <td nowrap="nowrap" class="online_izle style7 style18"><div align="right" class="style27">Telefon</div></td>
                     <td class="style25 style18 online_izle style28">:</td>
                     <td class="style13"><input name="Telefon" type="text" id="Telefon" size="35" /></td>
                   </tr>
                   <tr>
                     <td nowrap="nowrap" class="online_izle style7 style18"><div align="right" class="style27">Adresiniz</div></td>
                     <td class="style25 style18 online_izle style28">:</td>
                     <td class="style13"><input name="Adres" type="text" id="Adres" size="35" />
                     </td>
                   </tr>
                   <tr>
                     <td nowrap="nowrap" class="online_izle style7 style18"><div align="right" class="style27">Konu</div></td>
                     <td class="style25 style18 online_izle style28">:</td>
                     <td class="style13"><input name="Konu" type="text" id="Konu" size="35" /></td>
                   </tr>
                   <tr>
                     <td valign="top" nowrap="nowrap" class="online_izle style7 style18"><div align="right" class="style27">Mesajınız</div></td>
                     <td valign="top" class="style25 style18 online_izle style28">:</td>
                     <td class="style13"><textarea name="Mesaj" cols="40" rows="6" wrap="virtual" id="Mesaj"></textarea></td>
                   </tr>
                   <tr>
                     <td class="style19"><div align="right"></div></td>
                     <td class="style27">&nbsp;</td>
                     <td class="style13"><input name="button" type="submit" onclick="MM_validateForm('Eposta','','RisEmail');return document.MM_returnValue" value="Gönder" />
                       &nbsp;&nbsp;
                       <input type="reset" name="Submit2" value="Sil" /></td>
                   </tr>
                 </table>
                          </form>

    Yukarıdaki kodlarda görüldüğü üzere iletisim.html e giriliyor. Kişi bilgilerini vs dolduruyor. Gönder tuşuna bastıktan sonra http://www.xxx.com/iletisim.php yani iletisim.php e yönlendirdim. Fakat iletisim.php de burdaki bilgileri db e kayıt altına almam gerekli veya mail olarak bana gelmesi gerekiyor. Aslında talibim mail olarak gelmesinden yana fakat hangisi olursa kabul ederim. Bu form u submit ile nasıl mail ime tüm bilgiler ile birlikte gönderebilirim.

    Şimdiden teşekkür ederim.
  • 05-01-2009, 17:27:10
    #2
    Aşağıdaki şekilde belirttiğin maile alabilirsin, ancak ben boş gelen verileri kontrol etmedim onu ayarlamayı unutma yoksa spam yaparlar;
    <?
    $Gonderilecek_Email ="mailadresi@mail.com";
    
    $Gonderen_Ad_Soyad	= trim($_POST['Ad']);	# Gönderenin adý soyadý
    
    $Gonderen_Email		= trim($_POST['Eposta']);	# Gönderenin email adresi
    $Firma		= trim($_POST['Firma']);	
    $Telefon	= trim($_POST['Telefon']);	
    $Adres	= trim($_POST['Adres']);
    $Konu				= trim($_POST['Konu']);		# Mesajin konusu
    
    $Mesaj				= trim($_POST['Mesaj']);			# Mesaj
    
    
    
    $yonlen				= "index.php";				# Mail yollandiktan sonra yönlendirilecek sayfa
    $Konu = htmlspecialchars($Konu);
    
    $Mesaj = nl2br(htmlspecialchars($Mesaj));
    
    
    
    $Gidecek_Mesaj  = "<p>Gönderen: <strong>".$Gonderen_Ad_Soyad." &lt;".$Gonderen_Email."&gt;</strong></p>\n";
    
    $Gidecek_Mesaj .= "<p>Firma: <strong>".$Firma."</strong></p>\n\n";
    
    $Gidecek_Mesaj .= "<p>Telefon: <strong>".$Telefon."</strong></p>\n\n";
    
    $Gidecek_Mesaj .= "<p>Adres: <strong>".$Adres."</strong></p>\n\n";
    
    $Gidecek_Mesaj .= "<p>Konu: <strong>".$Konu."</strong></p>\n\n";
    
    $Gidecek_Mesaj .= "<p>Mesaj: ".$Mesaj."</p>\n\n";
    
    
    
    /*
    
       Formatlama iţlemi de tamamlandýđýna göre maili yollayabiliriz.
    
    */
    
    
    
    	$headers = "From: ".$Gonderen_Ad_Soyad." <".$Gonderen_Email."> \n";
    
    	$headers .= "X-Sender: <".$Gonderen_Email.">\n";
    
    	$headers .= "X-Mailer: ".$Gonderen_Ad_Soyad." \n";
    
    	$headers .= "X-Priority: 0 \n";
    
    	$headers .= "Return-Path: <".$Gonderen_Email.">\n";
    
    	$headers .= "In-Reply-To: <".$Gonderen_Email.">\n";
    
    	$headers .= "Reply-To: <".$Gonderen_Email.">\n";
    
    	$headers .= "MIME-Version: 1.0\n";
    
    	$headers .= "Content-Type: text/html; charset=windows-1254\n";
    
    	$yolla = mail($Gonderilecek_Email,$Konu,$Gidecek_Mesaj,$headers);
    
    	if ($yolla)
    
    		{
    
    		echo("<TABLE WIDTH=\"70%\" HEIGHT=\"100%\" ALIGN=\"CENTER\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\"><TR><TD ALIGN=\"CENTER\" VALIGN=\"MIDDLE\"><FONT SIZE=\"1\" FACE=\"Verdana, Arial, Helvetica, sans-serif\"><STRONG>\n");
    
    		echo("Email baţarýyla tarafýmýza ulaţtý. ilginiz için teţekkürler.</STRONG>Lütfen bekleyiniz ......<BR>Eđer 3 saniye içinde yönlendirme iţlemi baţlamazsa <A HREF=\"".$yonlen."\">buraya týklayýnýz.</A>\n");
    
    		echo("</FONT></TD></TR></TABLE>\n");
    
    		echo("<META HTTP-EQUIV=\"refresh\" CONTENT=\"3;URL=".$yonlen."\">");
    
    		}
    
    		else
    
    		{
    
    		$hata_mesaj = "Email yollama iţlemi sýrasýnda bir hata oluţtu !!";
    
    		echo("<TABLE WIDTH=\"70%\" HEIGHT=\"100%\" ALIGN=\"CENTER\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\"><TR><TD ALIGN=\"CENTER\" VALIGN=\"MIDDLE\">\n");
    
    		echo("<H3>HATA</H3><BR><FONT SIZE=\"1\" FACE=\"Verdana, Arial, Helvetica, sans-serif\">".$hata_mesaj." <A HREF=\"javascript:history.go(-1)\"> Geri dönmek için buraya týklayýnýz.</A>\n");
    
    		echo("</FONT></TD></TR></TABLE>\n");
    
    		}
    
    
    
    ?>
  • 05-01-2009, 17:33:02
    #3
    Hazırladığın form hoşuma gitti güzel yöntem. İlginiz için çok teşekkür ederim. Fakat dediğim gibi elimde olan bu form un üzerinde oynama yapmam gerekiyor. Bu konuda yardımlarınızı bekliyorum.
  • 05-01-2009, 17:38:29
    #4
    TTRehber adlı üyeden alıntı: mesajı görüntüle
    Hazırladığın form hoşuma gitti güzel yöntem. İlginiz için çok teşekkür ederim. Fakat dediğim gibi elimde olan bu form un üzerinde oynama yapmam gerekiyor. Bu konuda yardımlarınızı bekliyorum.
    İnput isimlerini zaten sizin verdiğiniz forma göre yaptım başka da bir işlem yapmaya gerek yok sadece boş verilerin kontrölünü sağlayacaksınız.
  • 05-01-2009, 17:51:58
    #5
    Evet süpersin macchess teşekkür ederim.
  • 05-01-2009, 18:38:58
    #6
    Macchess dediğin gibi boş verilerin sadece eposta bölümünün boş veri olarak girilmesini küçük bir js kodu ile engelledim. Ayrıca senin yazmış olduğun yönlendirmeyide kaldırdım. Fakat yönlendirmeyi kaldırdığımdan dolayı o sayfayı yenileyince aynı bilgiler tekrar geliyor bunu nasıl önleyebiliriz?
  • 05-01-2009, 18:57:36
    #7
    TTRehber adlı üyeden alıntı: mesajı görüntüle
    Macchess dediğin gibi boş verilerin sadece eposta bölümünün boş veri olarak girilmesini küçük bir js kodu ile engelledim. Ayrıca senin yazmış olduğun yönlendirmeyide kaldırdım. Fakat yönlendirmeyi kaldırdığımdan dolayı o sayfayı yenileyince aynı bilgiler tekrar geliyor bunu nasıl önleyebiliriz?
    Bunu cooike ile engellemek gerekir o da çok fazla ayrıntıya girer, yapacak birşey yok yani isteyen geri dönüp de tekrar butona basabilir.
  • 05-01-2009, 19:17:20
    #8
    Yinede verdiğin güzel bilgiler için teşekkür ederim. Bayağı yardımcı oldun. Biraz daha araştırmam gerekiyor sanırım..
  • 05-01-2009, 20:51:33
    #9
    Üyeliği durduruldu
    1. buna engel olmak için resimli güvenlik sistemi uygulaması yapabilirsiniz.
    2. basit bir çözüm olarak sayfaya gittiğinde tekrar göndermesin diye
    ilk gönderimde sessiona bir değer set edersiniz
    session_start();
    $_SESSION["gonderildi"]=1; 
    session register();
    sonrada buna göre kontrol edip gönderilmişse bir daha göndermezsin

    form olan sayfadada bu session değerini unset ederek forma girince tekrar göndermeye olanak sağlamış olursun