Jump to content
php.lv forumi

Mistika!


chizijs

Recommended Posts

Kods: http://paste.php.lv/bb13b5f28746b458da6f9975d8391e56?lang=php

Problēma ir tāda, kad ievāda nekorektu epastu, piemēram shis_nav_epasts parāda, ka epasts ir nepareizs, bet kad ievāda pareizu epastu, [email protected] tad echo 2; [ka epasts ir nepareizs] un nekādus datus neliek failā.

Uz PC viss labi iet, bet kad uzliku uz 000webhost.com hostinga, parādījas šī problēma

Edited by chizijs
Link to comment
Share on other sites

Kāpēc tev tā validemail() funkcija ir tik gara???

 

Lieto šito, jo viņa arī pārbauda MX serveri, tbš jefiņi nevarēs ievadīt e-pastu, piem. [email protected]:

function valid_email($email) { 
    if( (preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $email)) || 
     (preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$email)) ) { 
     $host = explode('@', $email);
     if(checkdnsrr($host[1].'.', 'MX') ) return true;
     if(checkdnsrr($host[1].'.', 'A') ) return true;
     if(checkdnsrr($host[1].'.', 'CNAME') ) return true;
    }
    return false;
   } 
     if (!function_exists('checkdnsrr')) {
    function checkdnsrr($host, $type = '') {
     if(!empty($host)) {
      if($type == '') $type = "MX";
      @exec("nslookup -type=$type $host", $output);
      while(list($k, $line) = each($output)) {
       if(eregi("^$host", $line)) {
        return true;
       }
      }
      return false;
     }
    }
   }

Edited by emsy
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...