PHP脚本甚至没有运行。当我点击“提交”时,它只会刷新页面。我甚至在没有表单上的操作的情况下测试了代码,它也做了同样的事情。我尝试使用提示按钮的按钮和输入。两者都不起作用。
以下是表单代码:
<form name="input" action="oakmanagement.com/SendEmployeeApplication.php" method="post">
<table>
<tr>
<!-- middle -->
<td style="width: 12px">
<table cellpadding="0" cellspacing="0">
<!-- for multiple images use the rel=gallery[mygallery]
<tr>
<td><a href="http://www.expressionofjoy.com/outreach/images/sm/Event_0000s_0008_Layer-5.jpg" class="lightview" rel="gallery[mygallery]" title="my caption"><img src="/images/photoGalleryHolder.jpg" border="0" /></a></td>
</tr>
-->
<tr>
<td><img src="/images/spacer.gif" height="10px" /></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><img src="/images/spacer.gif" height="10px" /></td>
</tr>
<tr>
<td><br /></td>
</tr>
</table>
</td>
<!-- spacing, do not touch -->
<td><img src="/images/spacer.gif" width="10px" /></td>
<!-- right -->
<td class="tdRightColumnTemplate">
<table cellpadding="0" cellspacing="0">
<tr>
<td class="txtXLargeBlack">Oak Management Employment - SITE UNDER CONSTRUCTION!</td>
</tr>
<tr>
<td><img src="/images/spacer.gif" height="20px" /></td>
</tr>
<tr>
<td>
<!-- form -->
<table>
<tr>
<td><img src="/images/spacer.gif" height="20px" /></td>
</tr>
<!-- /A head + field -->
<!-- Personal header -->
<tr><td colspan="2" bgcolor="#cdd0bd">
<!-- <input type="Hidden" value="" name="PERSONAL_SECTION" /> -->
<b class="txtNormalBlack" style="padding-top: 10px; padding-bottom: 10px; padding-left: 10px;">Personal:</b>
</td></tr>
<!-- /A head + field -->
<!-- head + field -->
<tr><td colspan="2">
<table border="0" width="100%" cellspacing="1" cellpadding="1" align="left" style="background-color: #dddddd; height: 200px;">
<tr>
<td align="left" id="t_fname" class="formFields">First</td>
<td align="left" class="formFields">Middle</td>
<td align="left" id="t_lname" class="formFields">Last Name</td>
<td align="left" id="t_email" class="formFields">E-mail</td>
</tr>
<tr>
<td align="left" class="formFields"> <INPUT TYPE="text" NAME="FIRST_NAME" VALUE="" SIZE="15" MAXLENGTH="30">
</td><td align="left" class="formFields"> <INPUT TYPE="text" NAME="MIDDLE_NAME" VALUE="" SIZE="15" MAXLENGTH="30">
</td><td align="left" class="formFields"> <INPUT TYPE="text" NAME="LAST_NAME" VALUE="" SIZE="15" MAXLENGTH="30">
</td><td class="formFields"><INPUT TYPE="text" NAME="EMAIL" VALUE="" SIZE="20" MAXLENGTH="60"></td>
</tr>
<tr bgcolor="#cccccc">
<td class="formFields" align="center" colspan="2">
<input type="submit" name="submit" value="Submit" />
<input type="reset" name="RESET" value="Reset" class="btnform" />
</td>
</tr>
</table>
</td></tr>
</table>
<!-- end of form -->
</td>
</tr>
<tr>
<td><img src="/images/spacer.gif" height="20px" /></td>
</tr>
</table>
</td>
</tr>
这是PHP:
function sendEmailToCompany() {
$from = stripslashes($_POST['EMAIL']);
$to = "mymail@mail.com";
$subject = "Employment Form For " . stripslashes($_POST['FIRST_NAME']);
$message = "Personal\n\nFirst Name: " . stripslashes($_POST['FIRST_NAME']) . "
\nMiddle Name: " . stripslashes($_POST["MIDDLE_NAME"]) . "
\nLast Name: " . stripslashes($_POST['LAST_NAME']) . "
\nE-mail: " . stripslashes($_POST['EMAIL']);
}
error_reporting(E_ERROR | E_PARSE);
sendEmailToCompany();
echo "<meta http-equiv='refresh' content='0;url=ThankYou.aspx'>";
?>
答案 0 :(得分:4)
您有<form><tr>
:这是不允许的。表单不能包含表的部分。表单必须完全包含在单个单元格中,否则整个表格必须采用表格形式。
您的浏览器可能正在纠错(此错误的错误恢复在所有浏览器中不一致),方法是在表格行开始之前关闭它,或者移动表单使其显示在表格之后(将控件留在后面)。
当您点击提交按钮时,您没有提交表单。
Validate您的HTML可以避免此类问题。
答案 1 :(得分:0)
你实际上并没有发送邮件,可能是为什么它不起作用!您正在准备所有数据,但没有通过邮件功能。
function sendEmailToCompany() {
$from = stripslashes($_POST['EMAIL']);
$to = "mymail@mail.com";
$subject = "Employment Form For " . stripslashes($_POST['FIRST_NAME']);
$message = "Personal\n\nFirst Name: " . stripslashes($_POST['FIRST_NAME']) . "
\nMiddle Name: " . stripslashes($_POST["MIDDLE_NAME"]) . "
\nLast Name: " . stripslashes($_POST['LAST_NAME']) . "
\nE-mail: " . stripslashes($_POST['EMAIL']);
// PART I HAVE ADDED...
mail($to, $subject, $message, $from);
// -------------------
}
error_reporting(E_ERROR | E_PARSE);
sendEmailToCompany();
echo "<meta http-equiv='refresh' content='0;url=ThankYou.aspx'>";
答案 2 :(得分:0)
检查此部分的代码:
echo "<meta http-equiv='refresh' content='0;url=ThankYou.aspx'>";
会将您重定向到页面 ThankYou.aspx
更改与PHP相同类型的网址参数
如果你给出条件,那会更好,所以你可以检查发送的电子邮件是否完美
if(sendEmailToCompany())
{
echo "<meta http-equiv='refresh' content='0;url=ThankYou.php'>";
//true condition
}
else
{
echo "error";
}
答案 3 :(得分:-4)
替换
<button type="submit">
Submit
</button>
使用
<input type="submit" name="submit" value="Submit" />
并替换
<form name="employment" action="./SendEmployeeApplication.php" method="post">
使用
<form name="employment" action="YOURDIRECTORY/SendEmployeeApplication.php" method="post">