Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Create account email validation


ianric

Recommended Posts

Posted

Hi

 

I have noticed that when you create an account, an empty or less than 5 chars in the email address field gives a popup but an email with no @ gives a standard error on the page. I have combined them into 1 and although I haven't had any testing failures, I just want to check with the experts if it's OK or will I get errors in the future. The standard code is

 

	if (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {
  $error = true;

  $messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_ERROR);
} elseif (tep_validate_email($email_address) == false) {
  $error = true;

  $messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
} else {
  $check_email_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'");
  $check_email = tep_db_fetch_array($check_email_query);
  if ($check_email['total'] > 0) {
	$error = true;

	$messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_ERROR_EXISTS);
  }
}

 

and I have changed the IF part and added an OR

 

	if (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH || (tep_validate_email($email_address) == false)) {
  $error = true;

  $messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
}  else {
  $check_email_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'");
  $check_email = tep_db_fetch_array($check_email_query);
  if ($check_email['total'] > 0) {
	$error = true;

	$messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_ERROR_EXISTS);
  }
}

 

Many thanks

 

Ian

Archived

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

×
×
  • Create New...