PDA

View Full Version : سوال: ارسال دعوتنامه



alih110
چهارشنبه 04 شهریور 1388, 17:02 عصر
چگونه میتونم یک فرمی طراحی کنم مثل معرفی به دوستان پارستولز که یک دعوتنامه به ایمیل دوستشما بفرسته . کسی میتونه کمک کنه.

yasgig
چهارشنبه 04 شهریور 1388, 17:13 عصر
<?
$body = '<div align="center">
<table cellpadding="0" cellspacing="0" width="785" dir="rtl" height="96" bgcolor="C#‎‎1E8BB">

<tr>
<td height="96" valign="top">
<font face="Tahoma" style="font-size: 9pt; font-weight:700">با سلام</font><p>
<font face="Tahoma" style="font-size: 9pt">این دعوتنامه از طرف یکی
از دوستان شما برای شما ارسال شده است تا شما از سایت ما بازدید
نمایید.جهت ورود به سایت ما بر روی لینک پایین کلیک نمایید<span lang="en-us">.</span></font></p>
<p align="center"><font face="Tahoma" style="font-size: 9pt">
<span lang="en-us"><a href="http://yasgig.ir">http://yasgig.ir</a></span></font></p>
<p align="right">
<font face="Tahoma" style="font-size: 12pt; font-weight:700">خدمات
ما:</font><br><font face="Tahoma" style="font-size: 9pt">ابزار
رایگان وب مسترها</font><br><font face="Tahoma" style="font-size: 9pt">خدمات
رایگان تحت وب</font><br><font face="Tahoma" style="font-size: 9pt">نمایندگی
هاست به صورت رایگان</font><br><font face="Tahoma" style="font-size: 9pt">طراحی وب
سایت</font><br><font face="Tahoma" style="font-size: 9pt">ثبت
دامنه</font><br><font face="Tahoma" style="font-size: 9pt">هاست
رایگان</font><br><font face="Tahoma" style="font-size: 9pt">سرگرمی و
...</font></td>
</tr>
</table>
</div>';

function send_mail_to_friend($mail_to,$mail_from)
{
global $body;
$mail_subject = "دعوتنامه";
if(mail($mail_to, $mail_subject, $body, "From: <$mail_from>\n"."MIME-Version: 1.0\n"."Content-type: text/html; charset=utf-8")) {
return true;
}
return false;
}

if(isset($_POST['send_mail']))
{

$mail_to = isset($_POST['to']) ? htmlspecialchars($_POST['to']) : '';
$mail_from = isset($_POST['from']) ? htmlspecialchars($_POST['from']) : '';

if(send_mail_to_friend($mail_to,$mail_from))
{
print('<p><p><center><font face="Tahoma" color="#003399" style="font-size: 9pt"><h1><i>با تشکر</i></h1><font color="#ff0000"> <br>لینک سایت به همراه توضیحات کامل برای دوست شما ارسال شد</font><br>از ارسال شما متشکریم<br><br><span style="cursor:hand" ONCLICK="window.history.go(-1);"> معرفی به یکی دیگر از دوستان </span></center></font>');
} else {
print('<p><p><center><font face="Tahoma" color="#003399" style="font-size: 9pt"><h1><i>دعوتنامه ارسال نشد</i></h1><font color="#ff0000"> <br>ارسال پیام معرفی با مشکل رو بروست لطفا دوباره تلاش کنید</font><br><br><span style="cursor:hand" ONCLICK="window.history.go(-1);">بازگشت</span><center></font>');
}
exit();
}
?>
<html dir="ltr">
<head>
<title>معرفی سایت به دوستان</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link id="StyleSheet" rel="stylesheet" type="text/css" href="../styles/stylefastyle.css">
</head>
<script type="text/javascript">
var ns6=document.getElementById&&!document.all
function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}
function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}
function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</b> کاراکتر'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true);
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true);
}
}
</script>
<SCRIPT language="JavaScript">
function CheckFormParstools () {

//Initialise variables
var errorMsg = "";

//Check for an e-mail address and that it is valid
if ((document.Contactform.from.value == "") || (document.Contactform.from.value.length > 0 && (document.Contactform.from.value.indexOf("@",0) == - 1 || document.Contactform.from.value.indexOf(".",0) == - 1))) {
errorMsg += "\n\n\t لطفا آدرس ایمیل خود را به صورت صحیح وارد نمایید ";
}

//Check for an e-mail address and that it is valid
if ((document.Contactform.to.value == "") || (document.Contactform.to.value.length > 0 && (document.Contactform.to.value.indexOf("@",0) == - 1 || document.Contactform.to.value.indexOf(".",0) == - 1))) {
errorMsg += "\n\n\t لطفا آدرس ایمیل دوست خود را به صورت صحیح وارد نمایید ";
}

//If there is aproblem with the form then display an error
if (errorMsg != ""){
msg = "\t\t : لطفا به خطاهای زیر توجه فرمایید\n";
msg += "__________________________________________________ _";

errorMsg += alert(msg + errorMsg + "\n________________________________________________ ___\n\n");
return false;
}

return true;
}
// -->
</script>
<body background="../images/main-bg.gif">
<form method="post" action="" name="Contactform" onSubmit="return CheckFormParstools();">
<div align="center">
<table border="0" width="100%" id="table1" dir="rtl" class="content">
<tr>
<td class="content" width="133">
ایمیل شما:</td>
<td class="content" width="990">
<input type="text" name="from" size="20" value="" onclick="this.value=''" class="textbox"></td>
</tr>
<tr>
<td class="content" width="133">
ایمیل دوست شما:</td>
<td class="content" width="990">
<input type="text" name="to" size="20" value="" onclick="this.value=''" class="textbox"></td>
</tr>
<tr>
<td width="133" class="content">
<input type="submit" value="معرفی به دوست" name="send_mail" id="fa0" class="content"></td>
<td width="990" class="content">&nbsp;</td>
</tr>
</table>
</div>
<td valign="top" width="181">
</form>
</body>
</html>موفق باشید

alih110
چهارشنبه 04 شهریور 1388, 17:48 عصر
فایل stylefastyle.css چی ؟؟؟

alih110
چهارشنبه 04 شهریور 1388, 17:50 عصر
همه این موارد با فرم ساده html و یک تابع php به نام mail شدنی هستش !

به نظر من خودت سعی کنی بنویسی همیشه توی ذهنت می مونه !

البته من راه موفقیت رو توی تلاش میبینم . و همیشه قبل از سوال تحقیق و در اینترنت سرچ می کنم !

البته می بخشید , فکر کردم سوالت رو اینطور جواب بدم بهتره !

یا علی

درسته حق با شما است ودرست میگید . اما من زیاد php بلد نیستم و html هم کم بلد هستم اما به زودی میخوام این ها رو یاد بگیرم .

از راهنماییتون ممنون .

alih110
چهارشنبه 04 شهریور 1388, 17:51 عصر
همه این موارد با فرم ساده html و یک تابع php به نام mail شدنی هستش !

به نظر من خودت سعی کنی بنویسی همیشه توی ذهنت می مونه !

البته من راه موفقیت رو توی تلاش میبینم . و همیشه قبل از سوال تحقیق و در اینترنت سرچ می کنم !

البته می بخشید , فکر کردم سوالت رو اینطور جواب بدم بهتره !

یا علی

حق باشماست . ولی من php بلد نیستم و html کمی بلدم . اما به زودی این ها رو یاد میگیرم .

از راهنماییتون ممنون استاد .

alih110
پنج شنبه 05 شهریور 1388, 01:36 صبح
چه طوری میشه کاری کرد که آخرش پس ارسال اون تشکر که میاد در یک صفحه ی جدید باشه .

yasgig
جمعه 06 شهریور 1388, 14:19 عصر
منظورتون رو متوجه نمی شم.مثلا از یه صفحه به صفحه دیگه پست بشه؟

alih110
جمعه 06 شهریور 1388, 16:12 عصر
منظورتون رو متوجه نمی شم.مثلا از یه صفحه به صفحه دیگه پست بشه؟
مشکل حل شد .

saeid99
جمعه 06 شهریور 1388, 20:13 عصر
فقط باید توجه اکید داشته باشین که یه دعوت نامه چندین بار استفاده نشه...

mohsen60
شنبه 07 شهریور 1388, 14:10 عصر
<?
$body = '<div align="center">
<table cellpadding="0" cellspacing="0" width="785" dir="rtl" height="96" bgcolor="C#‎‎‎1E8BB">

<tr>
<td height="96" valign="top">
<font face="Tahoma" style="font-size: 9pt; font-weight:700">با سلام</font><p>
<font face="Tahoma" style="font-size: 9pt">این دعوتنامه از طرف یکی
از دوستان شما برای شما ارسال شده است تا شما از سایت ما بازدید
نمایید.جهت ورود به سایت ما بر روی لینک پایین کلیک نمایید<span lang="en-us">.</span></font></p>
<p align="center"><font face="Tahoma" style="font-size: 9pt">
<span lang="en-us"><a href="http://yasgig.ir">http://yasgig.ir</a></span></font></p>
<p align="right">
<font face="Tahoma" style="font-size: 12pt; font-weight:700">خدمات
ما:</font><br><font face="Tahoma" style="font-size: 9pt">ابزار
رایگان وب مسترها</font><br><font face="Tahoma" style="font-size: 9pt">خدمات
رایگان تحت وب</font><br><font face="Tahoma" style="font-size: 9pt">نمایندگی
هاست به صورت رایگان</font><br><font face="Tahoma" style="font-size: 9pt">طراحی وب
سایت</font><br><font face="Tahoma" style="font-size: 9pt">ثبت
دامنه</font><br><font face="Tahoma" style="font-size: 9pt">هاست
رایگان</font><br><font face="Tahoma" style="font-size: 9pt">سرگرمی و
...</font></td>
</tr>
</table>
</div>';

function send_mail_to_friend($mail_to,$mail_from)
{
global $body;
$mail_subject = "دعوتنامه";
if(mail($mail_to, $mail_subject, $body, "From: <$mail_from>\n"."MIME-Version: 1.0\n"."Content-type: text/html; charset=utf-8")) {
return true;
}
return false;
}

if(isset($_POST['send_mail']))
{

$mail_to = isset($_POST['to']) ? htmlspecialchars($_POST['to']) : '';
$mail_from = isset($_POST['from']) ? htmlspecialchars($_POST['from']) : '';

if(send_mail_to_friend($mail_to,$mail_from))
{
print('<p><p><center><font face="Tahoma" color="#003399" style="font-size: 9pt"><h1><i>با تشکر</i></h1><font color="#ff0000"> <br>لینک سایت به همراه توضیحات کامل برای دوست شما ارسال شد</font><br>از ارسال شما متشکریم<br><br><span style="cursor:hand" ONCLICK="window.history.go(-1);"> معرفی به یکی دیگر از دوستان </span></center></font>');
} else {
print('<p><p><center><font face="Tahoma" color="#003399" style="font-size: 9pt"><h1><i>دعوتنامه ارسال نشد</i></h1><font color="#ff0000"> <br>ارسال پیام معرفی با مشکل رو بروست لطفا دوباره تلاش کنید</font><br><br><span style="cursor:hand" ONCLICK="window.history.go(-1);">بازگشت</span><center></font>');
}
exit();
}
?>
<html dir="ltr">
<head>
<title>معرفی سایت به دوستان</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link id="StyleSheet" rel="stylesheet" type="text/css" href="../styles/stylefastyle.css">
</head>
<script type="text/javascript">
var ns6=document.getElementById&&!document.all
function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}
function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}
function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</b> کاراکتر'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true);
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true);
}
}
</script>
<SCRIPT language="JavaScript">
function CheckFormParstools () {

//Initialise variables
var errorMsg = "";

//Check for an e-mail address and that it is valid
if ((document.Contactform.from.value == "") || (document.Contactform.from.value.length > 0 && (document.Contactform.from.value.indexOf("@",0) == - 1 || document.Contactform.from.value.indexOf(".",0) == - 1))) {
errorMsg += "\n\n\t لطفا آدرس ایمیل خود را به صورت صحیح وارد نمایید ";
}

//Check for an e-mail address and that it is valid
if ((document.Contactform.to.value == "") || (document.Contactform.to.value.length > 0 && (document.Contactform.to.value.indexOf("@",0) == - 1 || document.Contactform.to.value.indexOf(".",0) == - 1))) {
errorMsg += "\n\n\t لطفا آدرس ایمیل دوست خود را به صورت صحیح وارد نمایید ";
}

//If there is aproblem with the form then display an error
if (errorMsg != ""){
msg = "\t\t : لطفا به خطاهای زیر توجه فرمایید\n";
msg += "__________________________________________________ _";

errorMsg += alert(msg + errorMsg + "\n________________________________________________ ___\n\n");
return false;
}

return true;
}
// -->
</script>
<body background="../images/main-bg.gif">
<form method="post" action="" name="Contactform" onSubmit="return CheckFormParstools();">
<div align="center">
<table border="0" width="100%" id="table1" dir="rtl" class="content">
<tr>
<td class="content" width="133">
ایمیل شما:</td>
<td class="content" width="990">
<input type="text" name="from" size="20" value="" onclick="this.value=''" class="textbox"></td>
</tr>
<tr>
<td class="content" width="133">
ایمیل دوست شما:</td>
<td class="content" width="990">
<input type="text" name="to" size="20" value="" onclick="this.value=''" class="textbox"></td>
</tr>
<tr>
<td width="133" class="content">
<input type="submit" value="معرفی به دوست" name="send_mail" id="fa0" class="content"></td>
<td width="990" class="content">&nbsp;</td>
</tr>
</table>
</div>
<td valign="top" width="181">
</form>
</body>
</html>موفق باشید


در اين مورد تنظيمات PHPبه چه صورت هست؟
اين برنامه رو اجرا كردم و خطاي زير رو داد:

Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in c:\program files\easyphp1-8\www\test\ersale.php on line 31

yasgig
شنبه 07 شهریور 1388, 14:23 عصر
باید توی سرور اجرا کنی نه لوکال هاست