簡體   English   中英

在joomla 2.5中,如何將自定義php響應腳本添加到html表單?

[英]In joomla 2.5 how can I add a custom php response script to an html form?

我創建了一個自定義html表單模塊,因為我不喜歡將joomla擴展名用於表單等。原因是安裝新的表單擴展名需要我全面了解該擴展名,而我感到很煩。

所以這是我的自定義html表單代碼:

<form action="HereYouGo.php" method="post">
   <center>
      <input type="text" name="fullname" placeholder="Full Name" size="25" required>
      <input type="text" name="email" placeholder="Email" size="25" required>
      <input type="password" name="psw" placeholder="Password" size="25" required>
   </center><br>
   <input type="submit" value="Here You Go!"/><br><br>
   <center>
      <h4>By clicking "Here You Go!" you agree with our terms & conditions and private policy.</h4>
   </center>
</form>

誰能幫助我? 還要在joomla目錄中的哪個文件夾中放置我的響應PHP腳本。就我而言,我專門指的是“ HereYouGo.php”

幫助將不勝感激

為什么不創建類型為custom html的模塊,然后在其中添加代碼。 然后在需要的地方發布該模塊。

首先,我想建議最好創建自己的模塊或組件,然后再使用mod_html。 mod_html不適用於表單提交。 無論如何,如果仍然要繼續,那么可以在Joomla中創建一個文件夾,例如。 “自定義”並將php文件HereYouGo.php放在文件夾中。 在您的表單中,將customYou / HereYouGo.php替換為HereYouGo.php。 假設您已經安裝了sourcer插件。 所以你的表格看起來像

 {source} <!-- You can place html anywhere within the source tags --> <form action="custom/HereYouGo.php" method="post"><center><input name="fullname" required="" size="25" type="text" placeholder="Full Name" /> <input name="email" required="" size="25" type="text" placeholder="Email" /> <input name="psw" required="" size="25" type="password" placeholder="Password" /></center><br /> <input type="submit" value="Here You Go!" /><br /><br /><center> <h4>By clicking "Here You Go!" you agree with our terms &amp; conditions and private policy.</h4> </center> <script language="javascript" type="text/javascript"> // You can place JavaScript like this </script> <?php echo JHtml::_( 'form.token' ); ?> </form> {/source} 
JHtml :: _('form.token')是為了避免CSRF攻擊(跨站點請求偽造)

現在在您的PHP中,只需檢查表單令牌,然后繼續執行您想做的事情。 保存在數據庫等中或重定向到另一個頁面。 典型的php腳本應該具有這些代碼才能正常工作,因為它是外部腳本

  //Codes for accessing Joomla classes through external script define( '_JEXEC', 1 ); define( 'JPATH_BASE', realpath(dirname(__FILE__).'/..' )); require_once ( JPATH_BASE. '/includes/defines.php' ); require_once ( JPATH_BASE. '/includes/framework.php' ); $mainframe = JFactory::getApplication('site'); $mainframe->initialise(); //Codes for accessing Joomla classes Ends $session = JFactory::getSession(); $session->checkToken() or die( 'Invalid Token' ); //Check for form submission forgery // Instantiate the application. // Your code starts from here var_dump($_POST); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM