I have a quick (hopefully) question about checking to see if an email has already been entered in the database. I thought my prayers had been answered with &protectSubmit, but then I realized that it only works for that session (unless I’m mistaken?). I’m looking for a solution that won’t allow duplicate email addresses to be inserted into the database at any time. I am inserting my variables into my table just fine, but I’m not sure how to check against these variables using eForm. I’m assuming I need to select the email field, but after that I’m a little stumped (I’ve commented out my select call) - would I just throw in an if statement after that, or is there something else that needs to be done with eForm? I’ve never been a wiz at PHP on the best of days and adding in the eForm stuff is making this interesting. Thanks in advance for any tips and suggestions!<?php
function contestform( &$fields )
{
global $modx;
//$modx->db->select( 'email', 'summer' );
$dbTable = array();
$dbTable[postalcode] = $fields[postalcode];
$dbTable[email] = $fields[email];
$modx->db->insert( $dbTable, 'summer' );
return true;
}
return '';
?>