Bienvenido, Invitado
Recordarme

TEMA:

received form submission with invalid email 1 año 5 meses antes #242756

  • Autor del tema
  • jjspelman
  • Fuera de línea
  • Junior Breezer
  • Junior Breezer
  • Mensajes: 46
  • Gracias recibidas: 0
I just received a form submission from one of my forms and the email was Jennifer.iesha@gmail.om

I realize the validation only checks syntax but this is not a valid syntax?

Please advise.

www.j2studio.com/contact/graphic-design-request-for-quote

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

received form submission with invalid email 1 año 5 meses antes #242768

  • Avatar de TheMuffinMan
  • TheMuffinMan
  • Fuera de línea
  • Developer
  • Developer
  • Mensajes: 10064
  • Karma: 167
  • Gracias recibidas: 808
Hi,

".om" is actually a valid syntax but not valid in terms of semantics.

If you want it sort of bulletproof you need to create a validation that checks checks if the mailserver actually exists (MX DNS lookup) or create an ever-changing full list of TLDs.

We left that out because the latter can never complete and the first is not always working for every host (some hosting providers don't allow the use of PHP's checkdnsrr()):

- In you email field's validation, choose "custom"
- Copy the code below into the codebox and change FIELDNAME with the name (not title) of your email field:
function ff_FIELDNAME_validation(element, message)
    {
        let valid_email = ff_validemail( element, message );
        let valid_mx = true;

        JQuery.ajax({                                         //starts the ajax request
            type: "POST",					//define method "GET" or "POST"
            url: '<?php return JURI::getInstance()->toString() ?>',    	//the PHP file to call for DB queries or other processing
            data: {check_email: element.value},		//values to pass to the PHP file
            async: false, // we need it instantly
            success: function(data){//success callback function starts here
                console.log(data);
                valid_mx = data.valid_mx;

            }
        }); //ajax

        if (valid_email != ''  || !valid_mx) {
            if (message=='') message = element.name+" faild in my test.\n"
            ff_validationFocus(element.name);
            return message;
        } // if
        return '';
    }

- In form advanced => more options => form pieces => before form => click "custom"
- add the code below into the codebox:
if( JRequest::getVar('check_email', '') != '' ){

    if (ob_get_level()) ob_end_clean();
    while (ob_get_level()){
        ob_end_clean();
    }

    $result = new stdClass();
    $array = explode("@",JRequest::getVar('check_email', ''));
    $domain = array_pop($array);
    if(checkdnsrr($domain,"MX")){
        $result->valid_mx = true;
    } else {
        $result->valid_mx = false;
    }

    header('Content-Type: application/json');
    echo json_encode($result);
    exit;
    
}

Save and close and try the email validation.

As reference, I also attached you a working form to this reply.
To try it out, please download, unzip and import it in BF => Configuration => Package Installer.

Archivo Adjunto:

Nombre del Archivo: emailmxvalidation.zip
Tamaño del Archivo:7 KB


Regards,
Markus
Adjuntos:

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

  • Página:
  • 1
Moderadores: ForumSupport
Tiempo de carga de la página: 0.045 segundos