Exemple #1
0
     $value = str_replace(",", "", $value);
     $cPost[$key] = $dbFilter->dbPrepare($value);
 }
 //set mandatory fields
 $newsletter_conf['mandatories'] = array("fname", "sname", "email-reg-news");
 //set fields which must not contain numeric data
 $newsletter_conf['non_numeric'] = array("fname", "sname");
 //First, lets make sure there are is no numeric data in the name fields
 $userValidate = UserDataValidator::getInstance($newsletter_conf['mandatories'], '');
 if (!$userValidate->containsNumeric($cPost, $newsletter_conf['non_numeric'])) {
     //continue with processing
     //check mandatory information has been submitted
     if (FormValidator::checkMandatories($newsletter_conf['mandatories'], $cPost)) {
         //now check the email is a valid email
         //check email entered is a valid email
         $emailVerify = new EmailVerifier($cPost['email-reg-news']);
         if ($emailVerify->partVerify()) {
             //now we can check the entrant hasn't already entered
             //check for email already in database
             $sql = "SELECT count(*) FROM " . $newsletter_table . " where email='" . $cPost['email-reg-news'] . "'";
             $qry = mysql_query($sql);
             $results = mysql_fetch_array($qry);
             $count = $results[0];
             if ($count < 1) {
                 //haven't already entered, so enter them!
                 //insert record into table
                 $sql = "INSERT INTO " . $newsletter_table . " (fname, sname, email, ip, optin) VALUES ('" . $cPost['fname'] . "', '" . $cPost['sname'] . "', '" . $cPost['email-reg-news'] . "', '" . $ip . "', '" . $cPost['optin'] . "')";
                 $qry = mysql_query($sql, $db_object);
                 if (mysql_affected_rows($db_object) != 1) {
                     $success = false;
                     $returnVal = 'entry_other_error';
Exemple #2
0
 //collect users IP address
 $ip = $_SERVER['REMOTE_ADDR'];
 //check for email already in database
 $sql = "SELECT count(*) FROM " . $newsletter_table . " where email='" . $_cPOST['email-news'] . "'";
 $qry = mysql_query($sql);
 $results = mysql_fetch_array($qry);
 $count = $results[0];
 if ($count > 0) {
     //This is a dupe
     $news_error = "Your details are already registered for the newsletter";
     $success = false;
 }
 //check for valid email
 //check email is valid
 $okemail = false;
 $emlVerifier = new EmailVerifier($_cPOST['email-news'], "Email");
 if ($emlVerifier->partVerify()) {
     //Email address is valid
     $okemail = true;
 }
 unset($emlVerifier);
 //output error if email isnt valid
 if ($okemail == false && !empty($_cPOST['email-news'])) {
     $news_error = "The email address you have entered is not valid";
     $success = false;
 }
 if (!isset($news_error)) {
     //insert record into table
     $sql = "INSERT INTO " . $newsletter_table . " (fname, sname, email, ip, optin) VALUES ('" . $_cPOST['fname'] . "', '" . $_cPOST['sname'] . "', '" . $_cPOST['email-news'] . "', '" . $ip . "', '" . $_cPOST['optin'] . "')";
     $qry = mysql_query($sql, $db_object);
     if (mysql_affected_rows($db_object) != 1) {