2012-08-01 29 views
1

我讓自己的模塊將php表單的數據提交到數據庫中。我現在在一篇文章中有模塊。當在一篇文章中提交PHP表單時,Joomla 2.5 404錯誤

當我提交表單時,它會轉到404錯誤頁面,即使我有另一個成功提交的模板頁面。

我已經嘗試使用action = post.php以及確切的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> 

回答

0

你沒有代碼來處理表單提交。您需要添加一個隱藏字段,該字段將觸發處理表單提交的其他代碼,而不是顯示錶單。你需要像這樣的模塊 -

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應該在表單的隱藏字段而生成並且每個形式diaplyed時間散列。通過這種方式,您可以確認表單實際上是在您的網站上生成並提交的。