PHP İletişim Formu

Html uzantılı bir web sayfasına php iletişim formu nasıl yerleştirilir?

Öncelikle, iletişim formunu yerleştirmek istediğimiz html uzantılı sayfayı açıyoruz (dosyanın adı tercihen iletisim.html olabilir) ve aşağıdaki kodu "iletişim formu"nun olmasını istediğimiz yere yerleştiriyoruz:


PHP Kodu:

<form*action="feedback.php"*method="post">
<table*border="0"*cellpadding="8"*cellspacing="8"* summary="feedback*form">
<tr><td><font*face="Verdana"*size="2"*color="#2E2E 2E">İsminiz:</font></td><td>
<input*type="text"*name="name"*size="25"*/></td></tr>
<tr><td><font*color="#2E2E2E">
<font*face="Verdana"*size="2">E-Posta*Adresiniz</font>:</font></td><td>
<input*type="text"*name="email"*size="25"*/></td></tr>
<tr><td*colspan="2">
<font*face="Verdana"*size="2"*color="#2E2E2E">Mesa jınız</font>
<textarea*rows="15"*cols="45"*name="comments">
</textarea></td></tr><tr>
<td*align="center"*colspan="2">
<input*type="submit"*value="Gönder"*/>
</td></tr></table></form>*


Şimdi sıra geldi php scripte.. Yukardaki kodu yerleştiğimiz sayfayla aynı dizinde feedback.php isminde bir dosya oluşturuyoruz ve içerisine aşağıdaki kodları yerleştiriyoruz:


PHP Kodu:

<?
/*
****CHFEEDBACK.PHP*Feedback*Form*PHP*Script*Ver*2. 04
****Generated*by*thesitewizard.com's*Feedback*Form *Wizard.
****Copyright*2000-2005*by*Christopher*Heng.*All*rights*reserved.
****thesitewizard*and*thefreecountry*are*trademark s*of*Christopher*Heng.

****$Idphpscript.txt,v*1.4*2005/04/12*10:55:01*chris*Exp*$

****Get*the*latest*version,*free,*from:
********Free Feedback Form Wizard: Free Customized Feedback Form Script for Your Website (thesitewizard.com)

****You*can*contact*me*at:
********thesitewizard.com: Feedback Form

****LICENCE*TERMS
****
****1.*You*may*use*this*script*on*your*website,*wi th*or
****without*modifications,*free*of*charge.
****
****2.*You*may*NOT*distribute*or*republish*this*sc ript,
****whether*modified*or*not.*The*script*can*only*b e
****distributed*by*the*author,*Christopher*Heng.
****
****3.*THE*SCRIPT*AND*ITS*DOCUMENTATION*ARE*PROVID ED
****"AS*IS",*WITHOUT*WARRANTY*OF*ANY*KIND,*NOT*EVE N*THE
****IMPLIED*WARRANTY*OF*MECHANTABILITY*OR*FITNESS* FOR*A
****PARTICULAR*PURPOSE.*YOU*AGREE*TO*BEAR*ALL*RISK S*AND
****LIABILITIES*ARISING*FROM*THE*USE*OF*THE*SCRIPT ,
****ITS*DOCUMENTATION*AND*THE*INFORMATION*PROVIDED *BY*THE
****SCRIPTS*AND*THE*DOCUMENTATION.

****If*you*cannot*agree*to*any*of*the*above*condit ions,*you
****may*not*use*the*script.*
****
****Although*it*is*NOT*required,*I*would*be*most*g rateful
****if*you*could*also*link*to*thesitewizard.com*at :

*******thesitewizard.com: Website design, promotion, CGI, PHP, JavaScript scripting, and revenue earning.

*/

//*-------------*CONFIGURABLE*SECTION*------------------------

//*$mailto*-*set*to*the*email*address*you*want*the*form
//*sent*to,*eg
//$mailto********=*"youremailaddress@example.com"*;

$mailto*=*'example@gmail.com'*;

//*$subject*-*set*to*the*Subject*line*of*the*email,*eg
//$subject****=*"Feedback*Form"*;

$subject*=*"sohbetbebegi.Com iletisim*formu"*;

//*the*pages*to*be*displayed,*eg
//$formurl********=*"http://www.example.com/feedback.html"*;
//$errorurl********=*"http://www.example.com/error.html"*;
//$thankyouurl****=*"http://www.example.com/thankyou.html"*;

$formurl*=*"http://www.sizinsiteniz.com/iletisim.html"*;
$errorurl*=*"http://www.sizinsiteniz.com/error.html"*;
$thankyouurl*=*"http://www.sizinsiteniz.com/thanks.html"*;

//*--------------------*END*OF*CONFIGURABLE*SECTION*---------------

$name*=*$_POST['name']*;
$email*=*$_POST['email']*;
$comments*=*$_POST['comments']*;
$http_referrer*=*getenv(*"HTTP_REFERER"*);

if*(!isset($_POST['email']))*{
****header(*"Location$formurl"*);
****exit*;
}
if*(empty($name)*||*empty($email)*||*empty($commen ts))*{
***header(*"Location$errorurl"*);
***exit*;
}
$name*=*strtok(*$name,*"\r\n"*);
$email*=*strtok(*$email,*"\r\n"*);
if*(get_magic_quotes_gpc())*{
****$comments*=*stripslashes(*$comments*);
}

$messageproper*=

****"This*message*was*sent*from:\n"*.
****"$http_referrer\n"*.
****"-------------------------*COMMENTS*-------------------------\n\n"*.
****$comments*.
****"\n\n------------------------------------------------------------\n"*;

mail($mailto,*$subject,*$messageproper,*"From\"$ name\"*<$email>\r\nReply-To\"$name\"*<$email>\r\nX-Mailerchfeedback.php*2.04"*);
header(*"Location$thankyouurl"*);
exit*;

?>


Yukarıda yer alan kodlarda kendinize göre değişiklikler yapmanız gerekiyor..

$mailto = 'example@gmail.com' ; yazan kısma kendi mail adresinizi yazıyorsunuz. Bazı mail serverler gönderilen mailleri kabul etmemekte bu yüzden buraya yazacağınız adresiniz gmail uzantılı olursa gönderilen mailler size mutlaka ulaşacaktır.

$formurl = "http://www.sizinsiteniz.com/iletisim.html" ; sitenizin adı ve en üstteki html forum kodunu yerleştirdiğiniz dosya ismi (iletisim.html)

$errorurl = "http://www.sizinsiteniz.com/error.html" ; hata sayfası (iletişim forumu hata verirse kullanıcı bu sayfaya gönderilecek)

$thankyouurl = "http://www.sizinsiteniz.com/thanks.html" ; kullanıcıların mesajları başarıyla size iletildiğinde bu sayfaya (teşekkür sayfası diyelim) yöneltilecekler..

Bu adresleri kafanıza göre oluşturabilir ve gerekli ayarları yapabilirsiniz..

Özet olarak..........

1)en üstteki html kodunu, iletişim formunun olmasını istediğimiz yere yerleştiriyoruz (iletisim.html veya iletisim.php gibi)

2)feedback.php isminde dosya oluşturup, yukarda verdiğimiz php scripti kopyala yapıştır yapıyoruz.

3)kullanıcılar mesajlarını başarıyla gönderdiklerinde yönlendirilecekleri bir sayfa oluşturuyoruz (thanks.html gibi)

4)iletişim formu çalışmadığında yönlendirilecekleri, error (hata) sayfası oluşturuyoruz (error.html veya hata.html gibi)

5)feedback.php dosyasındaki ilgili yerleri yukarıdaki sayfa isimlerine göre ayarlıyorsunuz..**


bu script kendi geliştirdiğiniz php/html web sayfanızda kullanıma uygundur..

başarılar..