اضافه کردن فایل پیوست به فرم تماس

BomFunk

New Member
سلام دوستان من یک فرم تماس دارم که میخوام فایل پیوست به آن اضافه کنم، اگر امکان داره به من بگید که چه کدی رو باید اضافه کنم، ممنون
فرم HTML
[HTMLS]<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="Style.css">
<script type="text/javascript" src="city_state.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<h3>فرم ارسال نظرات در وب سایت</h3>
<form action="mailer.php" method="post">
<p>
<label for="name">نام :</label>
<input type="text" name="name">
</p>
<p>
شماره تماس: <input type="text" name="mobile" maxlength="25"/>
</p>
<p>
<label for="name">ایمیل :</label>
<input type="text" name="email">
</p>
<p>
موضوع چاپ : <select onChange="set_country(this,country,citystate)" size="1" name="category">
<option value="" selected="selected">انتخاب کنید</option>
<option value=""></option>
<script type="text/javascript">
setCategorys(this);
</script>
</select>
</p>
<p>
نوع چاپ : <select name="country" size="1" onChange="set_city_state(this,citystate)"></select>
</p>
<p>
سایز چاپ : <select name="citystate" size="1" onChange="print_city_state(country)"></select>
</p>
<p>
تیراژ : <input type="text" name="tiraj"/>
</p>
<p>
<label for="name"> کد پیگیری فیش پرداختی :</label>
<input type="text" name="cod">
</p>
<p>
<p><label for="attachment"> فایل ضمیمه:<span class="formats">تنها فرمتهای X , Y , Z </span></label>
<br />
<input type="file" name="attachment" id="attachment" /></p>
<p>
</p>
<p>
<label for="name"> توضیحات :</lable>
<textarea name="content"></textarea>
</p>
<input type="submit" value="ارسال" name="frm_submit">
</form>
</body>
</html>
[/HTMLS]

فایل mailer.php
[PHPS]<?php
if(isset($_POST['frm_submit']))
{

$name=htmlspecialchars($_POST['name']);
$mobile=htmlspecialchars($_POST['mobile']);
$email=htmlspecialchars($_POST['email']);
$category=htmlspecialchars($_POST['category']);
$country=htmlspecialchars($_POST['country']);
$citystate=htmlspecialchars($_POST['citystate']);
$tiraj=htmlspecialchars($_POST['tiraj']);
$cod=htmlspecialchars($_POST['cod']);
$content=htmlspecialchars($_POST['content']);
if(sendEmail($name,$mobile,$email,$category,$country,$citystate,$tiraj,$cod,$content)){
echo "Email Has Been Sent Successfully.";
}
else
{
echo "Send Email Was Failure.";
}
}
function sendEmail($name,$mobile,$email,$category,$country,$citystate,$tiraj,$cod,$content){
ob_start();
include 'template.php';
$html=ob_get_contents();
ob_end_clean();
$html= str_replace('{name}',$name, $html);
$html= str_replace('{mobile}',$mobile, $html);
$html= str_replace('{email}',$email, $html);
$html= str_replace('{category}',$category, $html);
$html= str_replace('{country}',$country, $html);
$html= str_replace('{citystate}',$citystate, $html);
$html= str_replace('{tiraj}',$tiraj, $html);
$html= str_replace('{cod}',$cod, $html);
$html= str_replace('{content}',$content,$html);
$headers = 'From: <a href="mailto:[email protected]">[email protected]</a>'. "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=utf-8' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

return mail("Admin<[email protected]>","درخواست جدید در وب سایت", $html, $headers);
}[/PHPS]




ممنون :rose:
 
آخرین ویرایش:

BomFunk

New Member
نمیدونم چرا کد های بالا این طوری نمایش داده می شوند اما کد های زیر سالم هستنند
فرم تماس
[HTMLS]<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="Style.css">
<script type="text/javascript" src="city_state.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<h3>فرم ارسال نظرات در وب سایت</h3>
<form action="mailer.php" method="post">
<p>
<label for="name">نام :</label>
<input type="text" name="name">
</p>
<p>
شماره تماس: <input type="text" name="mobile" maxlength="25"/>
</p>
<p>
<label for="name">ایمیل :</label>
<input type="text" name="email">
</p>
<p>
موضوع چاپ : <select onChange="set_country(this,country,citystate)" size="1" name="category">
<option value="" selected="selected">انتخاب کنید</option>
<option value=""></option>
<script type="text/javascript">
setCategorys(this);
</script>
</select>
</p>
<p>
نوع چاپ : <select name="country" size="1" onChange="set_city_state(this,citystate)"></select>
</p>
<p>
سایز چاپ : <select name="citystate" size="1" onChange="print_city_state(country)"></select>
</p>
<p>
تیراژ : <input type="text" name="tiraj"/>
</p>
<p>
<label for="name"> کد پیگیری فیش پرداختی :</label>
<input type="text" name="cod">
</p>
<p>
<p><label for="attachment"> فایل ضمیمه:<span class="formats">تنها فرمتهای X , Y , Z </span></label>
<br />
<input type="file" name="attachment" id="attachment" /></p>
<p>
</p>
<p>
<label for="name"> توضیحات :</lable>
<textarea name="content"></textarea>
</p>
<input type="submit" value="ارسال" name="frm_submit">
</form>
</body>
</html>[/HTMLS]

کد mailer.php
[PHPS]<?php
if(isset($_POST['frm_submit']))
{

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

return mail("Admin<[email protected]>","درخواست جدید در وب سایت", $html, $headers);
}[/PHPS]
 

جدیدترین ارسال ها

بالا