Joomla 2.5 404在文章中提交PHP表单时出错


Joomla 2.5 404 Error When Submitting PHP Form inside an Article

我制作了自己的模块,将php表单的数据提交到数据库中。我现在有一篇文章中的模块。

当我提交表单时,它会转到404错误页面,尽管我有另一个成功提交的模板页面。

我试过使用action=post.php以及确切的URL,但它失败了。

有人知道我做错了什么吗?

以下是URL:http://aubrey-joomla-test.freeiz.com/index.php/new-user-registration-form

以下是我的默认模板文件名:default_tmpl.php

这是我的tmpl代码:

<div>
    <form action="<?php echo JRoute::_('index.php'); ?>" method="post" id="myform" class="cols"  >
        <input type="hidden" name="form_send" value="send" />
        <h2>New User Registration Form</h2>
                <table>
                <label>Are you employed?</label>
                <tr>
                    <td><label><input type="radio" name="option" value="1" required="required">Yes</label></td>
                    <td><label><input type="radio" name="option" value="0" required="required">No</label></td>
                </tr>
                <label>If not, please proceed to the next section.</label>
                </table>
          <fieldset name="salary">
            <h4>Income From Employment</h4>             
                <table> <tr><label>Pay cycle:</label>
                    <td><label><input type="radio" name="option1" value="1" required="required">Monthly</label></td>
                    <td><label><input type="radio" name="option1" value="2" required="required">Biweekly</label></td>
                </tr> </table>
            <p><label>Please enter your typical pay: <input type="text" name="amountpay" required="required" pattern="'d+('.'d{2})?"/> </label></p>
            <p><label>Please select your next pay day: <input type="date" name="paydate"  required="required" /> </label></p>
          </fieldset>
          <fieldset name="fixeditems">
            <h4>Fixed Items</h4>
                <table> <label>Payment cycle:</label> <tr>
                <td><label><input type="radio" name="option2" value="1" required="required">Monthly</label></td>
                <td><label><input type="radio" name="option2" value="2" required="required">Biweekly</label></td>
                <tr>
                </table>
                <table> <label>Is this a form of:</label> <tr>
                    <td><label><input type="radio" name="option3" value="2" required="required">Income</label></td>
                    <td><label><input type="radio" name="option3" value="1" required="required">Expense</label></td>
                <tr>
                </table>        
            <p><label>Please enter the typical amount: <input type="text" name="amount" required="required" pattern ="'d+('.'d{2})?" /> </label></p>
            <p><label>Please select the next due date: <input type="date"  name="amountdate" required="required" /> </label></p>
          </fieldset>
          <hr>
          <div class="clear"></div>
          <button type="submit" name="send" value="Send">Submit form</button>
          <button type="reset">Reset</button>

</form>
</div>

您没有处理表单提交的代码。你需要添加一个隐藏字段,该字段将触发额外的代码来处理表单提交,而不是显示表单

if $_POST["form_submit_trigger"] :
PUT SOME CODE HERE TO HANDLE YOUR SUBMITTED DATA
else
PUT THE CODE TO DISPLAY YOUR FORM HERE

form_submit_trigger应该是表单中的一个隐藏字段,该字段在每次对表单进行解析时生成并散列。通过这种方式,您可以确认该表单实际上是在您的网站上生成并提交的。