2011-02-01 12 views
-3

**如何將提交表單的詳細信息發送至電子郵件ID?

<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="[email protected]"; 
$subject="Hello, sir/madam :"; 
$from="[email protected]"; 
$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> 

**

+2

您提供了代碼...您在這裏遇到了什麼問題? – 2011-02-01 11:40:20

+0

我是第二個Sarwar Erfan,你想做什麼? – 2011-02-01 11:42:37

回答

1

沒有 '從' 參數。這是您可以在其中指定的附加標題,答覆和otehr標題。如果你想從指定,你應該構建它的標題是這樣的:

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

另外的例子可以在php.net找到。

相關問題