Hey guys,
im not good at php at all, so im kinda stuck here
im trying to get recaptcha to work with virtuemart 1.0.15
i've tried all the tutorials and stuff but they only talk about the basic stuff like register.php and verify.php and it's different in virtuemart
can anyone help me out with this?
Well I'm a rookie myself with php, but I use recaptcha on one of my sites. Don't know much of anything about virtuemart, but substitute 'register.php' with whatever your registration page is called, you must have one. Then try something like this:
PHP Code:
require_once('recaptchalib.php');
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
die ("<h3>Image Verification failed!. Go back and try again.</h3>" .
"(reCAPTCHA said: " . $resp->error . ")");
}
Put that on your registration page prior to any HTML. By the way "recaptchalib.php" is a file you download from the recaptcha site. It is required.
Then, put the following somewhere in your form
PHP Code:
<?php
require_once('recaptchalib.php');
$publickey = "**************************";
echo recaptcha_get_html($publickey);
?>
You will need to use the private key somewhere too, but knowing nothing of your login system I can't tell you where or what to do with it.
thanks for the reply, this is what i got so far, i sorta changed around what u posted because of the way the code was setup, it's giving me an error, also it says that my cookies aren't enabled but they are, i never got that error before i changed the script
Code:
Info: Your browser does not accept cookies. To put products into your cart and purchase them you need to enable cookies.
Image Verification failed!. Go back and try again.
(reCAPTCHA said: incorrect-captcha-sol)
die ("<h3>Image Verification failed!. Go back and try again.</h3>" .
"(reCAPTCHA said: " . $resp->error . ")");
} if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); /** * * @version $Id: checkout_register_form.php 1612 2009-01-22 20:11:25Z thepisu $ * @package VirtueMart * @subpackage html * @copyright Copyright (C) 2004-2008 soeren - All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details. * * http://virtuemart.net */ mm_showMyFileName( __FILE__ ); global $mosConfig_allowUserRegistration, $mosConfig_useractivation; require_once( CLASSPATH . "ps_userfield.php" ); require_once( CLASSPATH . "htmlTools.class.php" );
$missing = vmGet( $_REQUEST, "missing", "" );
if (!empty( $missing )) { echo "<script type=\"text/javascript\">alert('".$VM_LANG->_('CONTACT_FORM_NC',false)."'); </script>\n"; }
// If not using NO_REGISTRATION, redirect with a warning when Joomla doesn't allow user registration if ($mosConfig_allowUserRegistration == "0" && VM_REGISTRATION_TYPE != 'NO_REGISTRATION' ) { $msg = $VM_LANG->_('USER_REGISTRATION_DISABLED'); vmRedirect( $sess->url( 'index.php?page='.HOMEPAGE, true, false ), $msg ); return; }
if( vmIsJoomla( '1.5' ) ) { // Set the validation value $validate = JUtility::getToken(); } else { $validate = function_exists( 'josspoofvalue' ) ? josSpoofValue(1) : vmSpoofValue(1); }
$fields = ps_userfield::getUserFields('registration', false, '', false ); // Read-only fields on registration don't make sense. foreach( $fields as $field ) $field->readonly = 0; $skip_fields = array();
if ( $my->id > 0 || (VM_REGISTRATION_TYPE != 'NORMAL_REGISTRATION' && VM_REGISTRATION_TYPE != 'OPTIONAL_REGISTRATION' && ( $page == 'checkout.index' || $page == 'shop.registration' ) ) ) { // A listing of fields that are NOT shown $skip_fields = array( 'username', 'password', 'password2' ); if( $my->id ) { $skip_fields[] = 'email'; } }
// This is the part that prints out ALL registration fields! ps_userfield::listUserFields( $fields, $skip_fields ); require_once('recaptchalib.php'); echo ' <div align="center">';
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
// Your code here to handle a successful verification
}
?>
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
// Your code here to handle a successful verification
}
?>
near the top of my registration.php page (prior to any html).
In regards to the error you're getting, it looks like you're trying to do this with session-based logins when you aren't using session-based logins. Maybe you are, maybe you aren't, like I said I don't know virtuemart. But it seems like you're trying to refer to a cookie that hasn't been set. As far as finding "verify.php", I couldn't tell you, I'm not using anything like that. It's all on the page in question, with one exception. The "private key" is set in the include file that handles my sessions and cookies. If you can tell me more about your login system I might be able to help more.
Bookmarks