首先,我想建議它更好地創建自己的模塊或組件,然後使用mod_html。 mod_html不適用於表單提交。無論如何,如果你仍然想繼續,那麼你可以在Joomla內創建一個文件夾例如。 「custom」並將php文件HereYouGo.php放入文件夾中。在你的表單中通過custom/HereYouGo.php替換HereYouGo.php。假設你已經安裝了源代碼插件。所以你的形式看起來像
{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 & 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);
這不是你的問題的答案。但我只是想讓我知道'
感謝您的更新......它仍然工作,雖然 –