0

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>&nbsp;</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&#45;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'>";
?>
4

4 回答 4

4

你有<form><tr>:这是不允许的。表单不能包含表格的一部分。表格必须完全包含在单个单元格中,或者整个表格必须在表格中。

您的浏览器可能通过在表格行开始之前关闭它或通过移动表单使其出现在表格之后(将控件留在后面)来进行错误纠正(此错误的错误恢复在所有浏览器中不一致)。

当您单击提交按钮时,您并未提交表单。

验证您的 HTML 以避免此类问题。

DOM 检查器中关闭表单的屏幕截图

于 2012-12-18T15:56:29.163 回答
0

在这部分检查您的代码:

echo "<meta http-equiv='refresh' content='0;url=ThankYou.aspx'>";

这将使您重定向到页面ThankYou.aspx

更改相同类型 PHP 的 url 参数

最好给个条件,这样可以检查发送的邮件是否完美

if(sendEmailToCompany())
{
   echo "<meta http-equiv='refresh' content='0;url=ThankYou.php'>";
   //true condition
}
else
{
  echo "error";
}
于 2014-10-06T23:17:26.287 回答
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'>";
于 2012-12-18T18:30:16.150 回答
-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">
于 2012-12-18T15:47:39.573 回答