簡體   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