PDA

View Full Version : سوال: مشکل در ارسال فرم به ایمیل



Navidshad
جمعه 06 تیر 1393, 13:32 عصر
سلام دوستان، من یه فورم ساده ساختم تا بتونم سفارش های چاپخانه را از طریق اینترنت دریافت کنم،
من میخواستم که یکسری dropdown لیست های مرتبط باهم بسازم، برای این کار یه سورس جاوا اسکریپت پیدا کردم که مربوت می شد به ارتباط بین قاره - کشور و شهر، حال من اینو دستکاری کردم و مقادیر خودم را جایگزین کردم حالا من میخوان این مقدار هایی که کاربر انتخاب میکنه رو به یک ایمیل در یک قالب از پیش تعریف شده ارسال کنم.
من یک آموزش پیدا کردم که نحوه ارسال فرم را به یک فایل php آموزش داده بود و همچنین جاگزین کردن مقادیر ارسال شده با قالب ایمیل، اما من مقادیر آموزش رو بسته به کار خودم تغییر دادم اما انگار فرم هیچ مقداری را ارسال نمی کند!!!!!!!! :گریه::گریه::گریه:
لطفا کمک کنید، ممنون

مقدار ها جایگزین شده:
CATEGORY = نوع محصول
COUNTRY = جنس محصول
CITY_STATE = سایز محصول

فرم html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>نوع > Country > Division</title>

<script type="text/javascript" src="city_state.js"></script>
</head>
<body>
<div id="widget">
<form action="mailer.php" method="get">
نام و نام خوانوادگی: <input type="text" name="name" maxlength="25"/>
</br>
</br>
شماره تماس: <input type="text" name="mobile" maxlength="25"/>
</br></br>
ایمیل: <input type="text" name="email"/>
</br></br>
category&raquo; <select onChange="set_country(this,country,city_state)" size="1" name="Category">
<option value="" selected="selected">انتخاب کنید</option>
<option value=""></option>
<script type="text/javascript">
setCategorys(this);
</script>
</select>
</br></br>
Material&raquo; <select name="country" size="1" disabled="disabled" onChange="set_city_state(this,city_state)"></select>
</br></br>
size&raquo; <select name="city_state" size="1" disabled="disabled" onChange="print_city_state(country,this)"></select>
</br></br>
تیراژ: <input type="text" name="tiraj"/>
</br></br>
شماره پیگیری فیش: <input type="text" name="serial"/>
</br></br>
<input type="submit" value="ارسال" name="frm_submit">

</form>
<div id="txtCategory"></div>
<div id="txtplacename"></div>
</div>
</body>
</html>

کد ارسال ایمیل

<?php
if(isset($_POST['frm_submit']))
{

$name=htmlspecialchars($_POST['name']);
$email=htmlspecialchars($_POST['email']);
$subject=htmlspecialchars($_POST['subject']);
$content=htmlspecialchars($_POST['content']);
if(sendEmail($name,$email,$subject,$content)){
echo "Email Has Been Sent Successfully.";
}
else
{
echo "Send Email Was Failure.";
}
}
function sendEmail($name,$email,$subject,$content){
ob_start();
include 'template.php';
$html=ob_get_contents();
ob_end_clean();
$html= str_replace('{name}',$name, $html);
$html= str_replace('{email}',$email, $html);
$html= str_replace('{subject}',$subject, $html);
$html= str_replace('{content}',$content,$html);
$headers = 'From: no-reply@domain.com'. "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=utf-8' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

return mail("Admin<admin_email@domain.com>","درخواست جدید در وب سایت", $html, $headers);
}

کد html قالب ایمیل

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body style="background-color: #EEE;width:100%;height:100%">
<div style="font-family: tahoma;font-size: 100%;direction: rtl;border:1px solid #CCC;width:500px; margin:50px auto;background-color: #FFF;border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
-moz-border-radius: 3px;
-ms-border-radius: 3px;">
<div style="width:100%;border-bottom: 2px solid #CCC;text-align: center;font-size: 10pt;padding: 20px 0;background-color:#DDD;">درخواست جديد از وب سايت شما</div>
<div style="font-size: 9pt;padding: 20px;line-height: 150%;">
<h4 style=" text-align: right;margin-bottom: 20px;color:#009;">مدير محترم وب سايت ،درخواست جديدي از وب سايت ارسال شده است</h4>
<p><span>نام ارسال کننده : </span>{name}</p>
<p><span>شماره تماس :</span>{mobile}</p>
<p><span>ايميل ارسال کننده :</span> {email}</p>
<p><span>دسته بندی :</span> {Category}</p>
<p><span>نوع کاغذ :</span> {country}</p>
<p><span>سایز :</span>{city_state}</p>
<p><span>تیراژ</span> {tiraj}</p>
<p><span>شماره پیگیری حساب</span> {serial}</p>
</div>
</div>
</body>

</html>

دوستان لطفا بنده را راهنمایی کنید، ممنون

Navidshad
جمعه 06 تیر 1393, 22:13 عصر
دوستان یک نگاه سرسری به این اسکریپت ها بندازید خواندنش راحت است، لطفا کمک کنید، خیلی ضروریه !!!!!!!!!!!!!!!:خجالت: