I am trying to implement reCaptcha in the Contact manager module of Joomla 1.5 from these instructions . I have the following form that looks like this:
<form action="<?php echo JRoute::_( 'index.php' );?>" method="post" name="emailForm" id="emailForm" class="form-validate">
<div class="contact_email<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>">
<label for="contact_name">
<?php echo JText::_( 'Enter your name' );?>:
</label>
<br />
<input type="text" name="name" id="contact_name" size="30" class="inputbox" value="" />
<br />
<label id="contact_emailmsg" for="contact_email">
<?php echo JText::_( 'Email address' );?>:
</label>
<br />
<input type="text" id="contact_email" name="email" size="30" value="" class="inputbox required validate-email" maxlength="100" />
<br />
<label for="contact_subject">
<?php echo JText::_( 'Message subject' );?>:
</label>
<br />
<input type="text" name="subject" id="contact_subject" size="30" class="inputbox" value="" />
<br /><br />
<label id="contact_textmsg" for="contact_text">
<?php echo JText::_( 'Enter your message' );?>:
</label>
<br />
<textarea cols="50" rows="10" name="text" id="contact_text" class="inputbox required"></textarea>
<?php if ($this->contact->params->get( 'show_email_copy' )) : ?>
<br />
<input type="checkbox" name="email_copy" id="contact_email_copy" value="1" />
<label for="contact_email_copy">
<?php echo JText::_( 'EMAIL_A_COPY' ); ?>
</label>
<?php endif; ?>
<br />
<br />
<button class="button validate" type="submit"><?php echo JText::_('Send'); ?></button>
</div>
<input type="hidden" name="option" value="com_contact" />
<input type="hidden" name="view" value="contact" />
<input type="hidden" name="id" value="<?php echo $this->contact->id; ?>" />
<input type="hidden" name="task" value="submit" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
In that index.php
file, I need to add some additional code so that when the form is submitted, the code is checked before the form is verified and sent.
I am assuming and therefore the reason I am here, that index.php is referring to the root index.php
file? Or if I am wrong, where is JRoute::_( 'index.php' );
pointing to?
In that index file I then need to reference recaptchalib.php like so:
require_once('templates/templatename/html/com_contact/contact/recaptchalib.php');
I am hoping that this is the correct way to reference recaptchalib.php from the index.php file?
JRoute::_("index.php") is indeed the root index.php. However the form you posted is incomplete, it's missing
<input type='hidden' name='option' value='mycomponent'
<input type='hidden' name='task' ...
option is the name of the component, so the file that handles your request is /components/com_mycomponent/mycomponent.php.
The function invoked in such component can be specified by the parameter 'task'.
Additionally, it's customary to specify controller, view and layout.
I guess you should insert your recaptcha require inside the view.
Read some info on Joomla MVC or at least MVC and learn from the core components :-)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.