2016-06-08 25 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感谢你够了阿米特先生..你真的花时间解释了所有这些..顺便说一句,我个人记录中,我位于印度..再次感谢一百万 –

相关问题