Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Email not valid message being displayed all the time


frasermathieson

Recommended Posts

Hi

 

I have added a reCaptcha onto my contact form and now the page is always displaying 'your email address seems to be invalid...' before the form is submitted. I have looked at the php code and it clear states that the stack should only be populated when the action is send but for some ready, the stack is being populated automatically. I have put the code below.

 

Thanks

Fraser Mathieson

 

<?php

/*

$Id: contact_us.php,v 1.42 2003/06/12 12:17:07 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

require('includes/meta_tags.php');

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CONTACT_US);

 

// start modification for reCaptcha

require_once('includes/classes/recaptchalib.php');

// end modification for reCaptcha

 

$error = false;

if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send')) {

$name = tep_db_prepare_input($HTTP_POST_VARS['name']);

$email_address = tep_db_prepare_input($HTTP_POST_VARS['email']);

$enquiry = tep_db_prepare_input($HTTP_POST_VARS['enquiry']);

 

// start modification for reCaptcha

// the response from reCAPTCHA

$resp = null;

 

// was there a reCAPTCHA response?

$resp = recaptcha_check_answer (RECAPTCHA_PRIVATE_KEY,

$_SERVER["REMOTE_ADDR"],

$_POST["recaptcha_challenge_field"],

$_POST["recaptcha_response_field"]);

 

if (tep_validate_email($email_address) & ($resp->is_valid)) {

tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $enquiry, $name, $email_address);

 

tep_redirect(tep_href_link(FILENAME_CONTACT_US, 'action=success'));

} else {

if (!tep_validate_email($email_address)) {

$error = true;

$messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);

}

if (!$resp->is_valid) {

$error = true;

$messageStack->add('contact', ENTRY_SECURITY_CHECK_ERROR . " (reCAPTCHA output: " . $resp->error . ")");

}

}

}

// end modification for reCaptcha

 

if (tep_validate_email($email_address)) {

tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $enquiry, $name, $email_address);

 

tep_redirect(tep_href_link(FILENAME_CONTACT_US, 'action=success'));

} else {

$error = true;

 

$messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);

}

var_dump($messageStack->size['contact']);

$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CONTACT_US));

 

and the part which is displayed

 

if ($messageStack->size('contact') > 0) {

?>

<tr>

<td><?php echo $messageStack->output('contact'); ?></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php

}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...