我是.net开发人员,我必须为php中的客户端做一些简单的工作。
我有一个包含4个表单的html页面(每个表单一个提交按钮)。
我将向您展示1个表单的代码(我有4个表单完全相同):
HTML:
<form method="post" class="af-form-wrapper" action="sendmail.php">
<div class="af-textWrap">
<input id="fullName" type="text" placeholder="Your name" name="fullName" class="text" value="" tabindex="500" required />
</div>
<div class="af-textWrap">
<input class="text" placeholder="Your email" id="email" type="text" name="email" value="" tabindex="501" required />
</div>
<div class="af-element buttonContainer">
<input name="submit" class="submit" type="submit" value="" tabindex="503" />
</div>
</form>
PHP:
<?php
$EmailTo = "xxx@gmail.com";
$Subject = "Details left";
$Name = Trim(stripslashes($_POST['fullName']));
$Email = Trim(stripslashes($_POST['email']));
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$headers = 'From: xxxx@contact.com' . "\r\n" .
'Reply-To: xxxx@gmail.com' . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($EmailTo, $Subject, $Body, $headers))
/* Redirect browser */
header("Location: secondPage.html");
/* Make sure that code below does not get executed when we redirect. */
else
echo "Email sending failed";
?>
邮件正常运行。 字段(姓名和电子邮件)文字,不要。 这有什么不对?
$_POST['fullName'])
fullName-是id还是名字?
我想要实现的目标 - 每个表单(4个表单,4个提交按钮) 假设我正在填写第3个表格并点击3&#f;表格按钮 将发送一封电子邮件,其中包含来自3表格字段(而非其他表格)的姓名和电子邮件文本