在发送提交按钮,电子邮件表格数据为doc

时间:2017-09-11 05:01:22

标签: php html forms email

我有一个代码,当我单击“发送”按钮时,表单数据将作为Word文档(.doc)下载。我需要做的是,当我单击提交按钮时,我希望将此.doc文件作为doc文件附件通过电子邮件发送。我现在正尝试从当地主机那里做。

的index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>



<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

<style>

h1 {

height: 50px;

width: 100%;

font-size: 18px;

background: #FFA500;

color: white;

line-height: 150%;

border-radius: 3px 3px 0 0;

box-shadow: 0 2px 5px 1px rgba(0, 0, 0, 0.2);

}


h3 {

height: 50px;

width: 100%;

font-size: 18px;

background: white;

color: #18aa8d;

line-height: 150%;

border-radius: 3px 3px 0 0;



}

form {

box-sizing: border-box;

width: 500px;

margin: 100px auto 0;

box-shadow: 2px 2px 5px 1px rgba(0, 0, 0, 0.2);

padding-bottom: 40px;

border-radius: 3px;

}

form h1 {

box-sizing: border-box;

padding: 20px;

}

.text-field {

margin: 40px 25px;

width: 80%;

display: block;

border: none;

padding: 10px 0;

-webkit-transition: all 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);

transition: all 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);

background: -webkit-linear-gradient(top, rgba(255, 255, 255, 0) 96%, #1abc9c 4%);

background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 96%, #1abc9c 4%);

background-position: -100% 0;

background-size: 100% 100%;

background-repeat: no-repeat;

color: #0e6252;

}

.text-field:focus, .text-field:valid {

box-shadow: none;

outline: none;

background-position: 0 0;

border-bottom: solid 1px #1abc9c;

}

button {

float:right;

border: none;

background: #1abc9c;

cursor: pointer;

border-radius: 3px;

padding: 6px;

width: 40px;

color: white;

margin-right: 40px;

box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.2);

}

button:hover {

-webkit-transform: translateY(-3px);

-ms-transform: translateY(-3px);

transform: translateY(-3px);

box-shadow: 0 6px 6px 0 rgba(0, 0, 0, 0.2);

} 
.text-field-1 {

background:none;

}

</style>

</head>

<body>

<form method="POST" action="word.php">

<h1>Resume</h1>

<h3>Career Objective:</h3>

<textarea rows="3" cols="6"  name="obj" placeholder="Objective"  class="text-field text-field-1"></textarea>

<h3>Personal Details:</h3>

<input placeholder="Name" name="name" class="text-field" type="text" required="">

<textarea rows="3" cols="6"  name="address" placeholder="Address"  class="text-field text-field-1"></textarea>

<input placeholder="Phone Number" name="number" class="text-field" type="text" required="">

<input placeholder="Email" name="Email" class="text-field" type="text" required="">

<input placeholder="DOB-dd/mm/yyy" name="dob" class="text-field" type="text" required="">

<input placeholder="Nationality" name="nation" class="text-field" type="text" required="">

<input placeholder="Maritial Status" name="status" class="text-field" type="text" required="">


<h3>Education:</h3>


<textarea rows="6" cols="12"  name="education" placeholder="10th, 12th and Graduation"  class="text-field text-field-1"></textarea>


<h3>Experiance:</h3>


<textarea rows="6" cols="12"  name="exper" placeholder="Company and years worked"  class="text-field text-field-1"></textarea>

<h3>Languages:</h3>


<textarea rows="6" cols="12"  name="lang" placeholder="Languages Known"  class="text-field text-field-1"></textarea>


<h3>Skills:</h3>


<textarea rows="6" cols="12"  name="skill" placeholder="Skills"  class="text-field text-field-1"></textarea>

<h3>Intersts:</h3>


<textarea rows="6" cols="12"  name="interest" placeholder="Interests"  class="text-field text-field-1"></textarea>


<h3>Projects:</h3>


<textarea rows="6" cols="12"  name="project" placeholder="Projects"  class="text-field text-field-1"></textarea>


<h3>Personal Qualities:</h3>


<textarea rows="6" cols="12"  name="qual" placeholder="Your Personal Qualities"  class="text-field text-field-1"></textarea>


<h3>Achievements:</h3>


<textarea rows="6" cols="12"  name="achievements" placeholder="Achievements"  class="text-field text-field-1"></textarea>


<h3>References:</h3>


<textarea rows="6" cols="12"  name="references" placeholder="References"  class="text-field text-field-1"></textarea>



















<button type="submit" name="word">Doc</button> &nbsp;&nbsp;&nbsp;

</form>

</body>

</html>



<!-- <input placeholder="Heading" name="heading" class="text-field" type="text" required="">

<textarea rows="3" cols="6"  name="content" placeholder="content"  class="text-field text-field-1"></textarea> -->

word.php

<?php

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

header("Content-type: application/vnd.ms-word"); 

# replace Wordfile.doc with whatever you want the filename to default to

header("Content-Disposition: attachment;Filename=resume.doc");

header("Pragma: no-cache");

header("Expires: 0");

$current_date = date('d-m-Y');


$obj = $_POST['obj'];

$name = $_POST['name'];

$address = $_POST['address'];

$number = $_POST['number'];
$Email = $_POST['Email'];
$dob = $_POST['dob'];
$nation = $_POST['nation'];
$status = $_POST['status'];
$education = $_POST['education'];
$exper = $_POST['exper'];
$lang = $_POST['lang'];
$skill = $_POST['skill'];
$interest = $_POST['interest'];
$project = $_POST['project'];
$qual = $_POST['qual'];
$achievements = $_POST['achievements'];
$references = $_POST['references'];


echo "Report Date: $current_date \n\n";

echo "Career Objective:\n\n";

echo "$obj \n\n";

echo "Personal Details:\n\n";

echo "Name: $name\n\n";

echo "Address: $address\n\n";
echo "Phone Number: $number\n\n";
echo "E-mail: $Email\n\n";
echo "Date of Birth: $dob\n\n";
echo "Nationality: $nation\n\n";
echo "Maritial Status: $status\n\n";

echo "Education:\n\n";


echo "$education \n\n";



echo "Experiance:\n\n";

echo "$exper \n\n";

echo "Languages:\n\n";

echo "$lang \n\n";

echo "Skills:\n\n";

echo "$skill \n\n";

echo "Interest:\n\n";

echo "$interest \n\n";
echo "Project:\n\n";

echo "$project \n\n";



echo "Achievements:\n\n";

echo "$achievements \n\n";

echo "Personal Qualities:\n\n";

echo "$qual \n\n";

echo "References:\n\n";

echo "$references \n\n";


}

?>

任何帮助将不胜感激。三江源

0 个答案:

没有答案