Programalama > PHP

Etiketler: php, formmail

Ort. 0
Puan ver:
<form method="post" action="formmail.php"> 
<input type="hidden" name="recipient" value="[BURAYA MAIL ADRES YAZ]"> 
<input type="hidden" name="subject" value="[KONU YAZ]"> 
<input type="hidden" name="req" value="[GEREKLİLİĞİ KONTROL EDİLECEK ALANLARI VİRGÜLLE AYIRIP YAZ]"> 
[Formun geri kalanını istediğin gibi yapılandır]
</form> 
--------------------------------------------------------------------------
[Bu kısmı formmail.php dıye kaydedin]
<html> 
<head> 
<title>Formmail</title> 
</head> 
<body bgcolor="black"> 

<? 
//---------------------------------- 
// OPTIONAL PARAMETERS 
//---------------------------------- 

// Message header such as "confirm" or "error" 
$headersize="4"; 
$headercolor="Lime"; 
// Message body 
$textsize="3"; 
$textcolor="0000ff"; 
$linkcolor="ffcc99"; 


/*****************************************************/ 
/* YOU DO NOT NEED TO MODIFY ANYTHING BELOW */ 
/***************************************************/ 




if( !empty($HTTP_POST_VARS)) 
{ 
// if any form submission start the process 
function prompt_user($messageheader,$promptmessage) 
{ 
global $l,$goback,$fm_error,$plsfill,$invalidaddress,$fm_confirm,$sent,$unsent,$author; 
global $headersize,$headercolor,$textsize,$textcolor,$linkcolor; 
include("inc/Header.php"); 
echo " 

<center> 
<B><font size=\"$headersize\" color=\"$headercolor\"> 
----------------------------<br> 
:: ::<br> 
----------------------------<br> 
</font> 
<br> 
<font size=\"$textsize\" color=\"$textcolor\"> 
Mesajınız Gönderildi!..</font> 
<br><br> 
<a href='javascript:history.go(-2)'> 
<font size='2' color='$linkcolor'>Back Main</font></a> 
<B></center>"; 
exit; 
} 

// function to check the empty fields 
function check_fields($fieldname,$fieldtype) 
{ 
global $fm_error,$plsfill; 
if (empty($fieldname)) 
{ 
prompt_user("$fm_error","$plsfill <br> * $fieldtype"); 
} 
} 

// function to check the email validity 
function check_email($mailtocheck) 
{ 
global $fm_error,$plsfill,$invalidaddress; 
$mail_test= trim($mailtocheck); 
if (!eregi("^[_\\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\\.)+[a-z]{2,3}$", $mail_test)) 
{ 
prompt_user("$fm_error","$invalidaddress :<br> $mail_test"); 
} 
} 

// check if there are required fields 
if ($req) 
{ 
$requiredfields=explode(",",$req); 
for ($temp=0;$temp<count($requiredfields);$temp++) 
{ 
$requiredfields[$temp]=trim ($requiredfields[$temp]); 
if ($requiredfields[$temp]=="email") 
{ 
check_email("${$requiredfields[$temp]}"); 
} 
else 
{ 
check_fields ("${$requiredfields[$temp]}","$requiredfields[$temp]"); 
} 
} 
} 

/* default values for script will take place in the hidden form fields */ 
$def[]="subject"; 
$def[]="req"; 
$def[]="recipient"; 

// get the IP and the date 
$ip=getenv("REMOTE_ADDR"); 
$date=date("d-m-Y H:i:s"); 

// message body 
$message=$defaultmessage."\n\n"; 
$message.="From :".$email."\n"; 
$message.="Date :".$date."\n"; 
$message.="IP :".$ip."\n"; 
$message.="------------------------------------\n"; 
foreach($HTTP_POST_VARS as $formfield => $value) 
{ 
$found=0; 
for($i=0;$i<count($def);$i++) 
{ 
if($formfield==$def[$i]) 
{ 
$found=1; 
} 
} 
if(!$found==1) 
{ 
$message.=$formfield." : ".$value."\n"; 
} 
} 
$message.="------------------------------------\n\n\n"; 
$message.=""; 
$headers ="From: $email\n"; 

// check the subject 
if(!$subject) 
{ 
$subject=$defaultsubject; 
} 

// mail the form 
if(@mail($recipient,$subject,$message,$headers)) 
{ 
prompt_user("$fm_confirm","$sent"); 
echo"<center></center>"; 
} 
else 
{ 
prompt_user("$fm_error","$unsent"); 
echo"<center></center>"; 
} 
} 
else 
{ 
echo"<center><font face=System color=lime> <br> 
 Mesaj gonderilmedi!..<br>Fatal ERROR: 000FFFFx000DEEE</font></center>"; 
} 

?> 
</body> 
</html>


Yorumlar                 Yorum Yaz
Bu hazır kod'a ilk yorumu siz yapın!
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2024 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSOBİL projesidir.