繁体   English   中英

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

[英]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应该是表单中的一个隐藏字段,该字段在每次拆分表单时都会生成并散列。 这样,您可以确认表单是实际生成的,并已在您的站点上提交。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM