如何将提交的表单详细信息发送到电子邮件ID?

时间:2011-02-01 11:35:50

标签: php

**

<html>
<body>
<?php
print "<form name='frmone' action='s1show.php' method='post' enctype='multipart/form-data'>";
print "Enter Your Name : <input type='text' name='name' /> </br>";
print "Enter Your Qualification : <input type='text' name='qln' /> </br> ";
print "Enter Your Place Living: <input type='text' name='place' /> </br> ";
print "Enter Your Country Name : <input type='text' name='country' /> </br>";
print "<input type='submit' value='SUBMIT' onclick='javascript : return validatedetails();'>";
print "</form>";
?>
</body>
</html>
<script language=javascript>
function validatedetails()
 {
  if(document.frmone.name.value=="")
   {
   alert("Please Enter Your Name");
   frmone.name.focus();
   return false;   
   }

  if(document.frmone.qln.value=="")
   {
   alert("Please Enter Your Qualification");
   frmone.qln.focus();
   return false;
   }

  if(document.frmone.place.value=="")
   {
    alert("Please Enter Your Place Name");
    frmone.place.focus();
    return false;   
   }

  if(document.frmone.country.value=="")
   {
    alert("Please Enter Your Country Name");
    frmone.country.focus();
    return false;   
   }

  frmone.submit();
  return true; 
 }
</script>

流程点击形式低于.....

<html>
<body>
<?php
$to="rylonhunt@gmail.com";
$subject="Hello, sir/madam :";
$from="rylonhunt@gmail.com";
$body ="The personal details are show below : \n\n";
$body .= "Name :" . $_REQUEST['name'] . "\n\n" ;
$body .= "Qualification :" . $_REQUEST['qln'] . "\n\n" ;
$body .= "Place Name :" . $_REQUEST['place'] . "\n\n" ; 
$body .="Country Name :" . $_REQUEST['country'];
if(mail($to,$subject,$body,$from))
 {
 echo "Thank You, Your Details has been sent to your mail";
 }
else 
 {
 echo "Email has not been sent..";
 }
?>
</body>
</html>

**

1 个答案:

答案 0 :(得分:1)

没有'from'参数。这是您可以在其中指定,回复和otehr标头的附加标头。如果你想指定from,你应该像这样构建一个标题:

....
$header = "From: $from";
if(mail($to,$subject,$body,$header))
....

可以在php.net上找到其他示例。