PHP不起作用

时间:2012-02-18 12:14:33

标签: php

我有一个PHP表单和HTML,如下所示:

<!DOCTYPE html>
<html>
<head>
    <title>Page Title</title>
</head>
<body>
<form>
<form action="emailform.php" method="post"> 
<table width="400" border="0" cellspacing="2" cellpadding="0"> 
<tr> 
<td width="29%" class="bodytext">Your name:</td> 
<td width="71%"><input name="name" type="text" id="name" size="32"></td> 
</tr> 
<tr> 
<td class="bodytext">Email address:</td> 
<td><input name="email" type="text" id="email" size="32"></td> 
</tr> 
<tr> 
<td class="bodytext">Comment:</td> 
<td><textarea name="comment" cols="45" rows="6" id="comment" class="bodytext"></textarea></td> 
</tr> 
<tr> 
<td class="bodytext">&nbsp;</td> 
<td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td> 
</tr> 
</table> 
</form>
</form>
</body>
</html>

和emailform.php

<?php 
if ($_POST["email"]<>'') { 
    $ToEmail = 'slmnwise@gmail.com'; 
    $EmailSubject = 'Site contact form '; 
    $mailheader = "From: ".$_POST["email"]."\r\n"; 
    $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
    $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
    $MESSAGE_BODY = "Name: ".$_POST["name"]."<br>"; 
    $MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>"; 
    $MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."<br>"; 
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
?> 
Your message was sent
<?php 
} else {
}
?> 

我将它们放在单独的页面中并尝试执行发送电子邮件的操作,但没有任何反应,它只是显示不同的URL并保持这种状态。上网工作需要吗?或者我做错了什么

1 个答案:

答案 0 :(得分:3)

您有一个表单嵌套在另一个表单中。删除<form>和一个</form>