2016-06-08 28 views
0

我創建了一個自定義html表單模塊,因爲我不喜歡使用表單等的joomla擴展。原因是安裝一個新的表單擴展需要我瞭解所有的擴展,我覺得很討厭。在joomla 2.5中如何添加一個自定義的php響應腳本到一個html表單?

因此,這裏是我的自定義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」

幫助應是極大的讚賞

+0

這不是你的問題的答案。但我只是想讓我知道'

'標記已被[棄用](http://stackoverflow.com/questions/1798817/why-is-the-center-tag-deprecated-in-html)。現在有一段時間了 –

+0

感謝您的更新......它仍然工作,雖然 –

回答

0

你爲什麼不創建一個模塊自定義html類型並在其中添加代碼。 然後在需要的地方發佈模塊。

+0

我的意思是我已經創建「一個類型自定義html的模塊」作爲你引用..我問的是我在哪裏放置php代碼這將響應HTML格式..此外,我在joomla中使用sourcerer插件...我可以將響應PHP代碼本身? –

+0

不要去工具 - >源代碼。直接在出現的文本框中添加{source}所有以 {/ source}開頭的php代碼。這應該適合你。 –

+0

謝謝你......也在考慮那個選項呢..會試着照你所說的..再次感謝 –

0

首先,我想建議它更好地創建自己的模塊或組件,然後使用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 &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); 
+0

我不能多謝你,阿米特先生......你真的花時間來解釋所有這些......順便說一句,一個人的筆記,我也位於印度..感謝一百萬 –

+0

@ KennyKamei你是最受歡迎的。如果問題得到解決,您也可以將其標記爲已解決。 –

+0

以及我創建了自己的catergory「自定義html」模塊......然後通過sourcerer將我的html表單代碼插入到模塊中......如果這是你的意思,我不使用mod_html擴展...反正Icant感謝你夠了阿米特先生..你真的花時間解釋了所有這些..順便說一句,我個人記錄中,我位於印度..再次感謝一百萬 –

相關問題