I created a custom html form module because I don't like using joomla extensions for forms etc. The reason is installing a new form extension requires me to learn about the extension all over and I find that annoying.
So here's my custom html form code:
<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>
Anyone who can help me? Also which folder in joomla directory should I place my response PHP script.. In my case I'm specifically referring to "HereYouGo.php"
Help shall be greatly appreciated
Why don't you create a module of type custom html and add the code there. Then publish the module wherever you need.
First I would like to suggest that its better to create your own module or component then to use mod_html. mod_html was not meant for form submission. Anyways if still you want to proceed, then you can create a folder inside Joomla eg. "custom" and place the php file HereYouGo.php inside the folder. In your form replace HereYouGo.php by custom/HereYouGo.php. Assuming you have installed sourcer plugin. So your form looks like
{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' ) is to avoid CSRF Attack (Cross Site Request Forgery)
Now in your php just check the form token and then proceed what you want to do. Save in database etc. or redirect to another page. Typical php script should have these codes to work properly as it is an external script
//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);
</div>