Search the Community
Showing results for tags 'dns_get_record'.
-
My first question: I have a message like this: notice: undefined offset 0 I use an input form to check with dns_get_record and DNS_MX whether the domain of an email exists. I can check the emails if the domain does exist, but a wrong domain like: mail@verynonexistingdomain.com throws in the notice undefined offset 0 so does an empty input. <html> <center> <br> email input :<br> <form action="#" method = "post"> <input type ="text" name ="mail"> <br> <input type="submit" name = "click" value ="zend"> </form> <?php $domain =''; $data =''; var_dump($_POST['click']); var_dump($_POST['mail']); if (isset($_POST['mail'])) { echo $_POST['mail']; $input = $_POST['mail']; } // // function check_address($input){ list($user, $domain) = explode('@', $input); $data= dns_get_record($domain, DNS_MX); if($data[0]['host']==$domain&&!empty($data[0]['target'])) { return $data[0]['target']; } else { }} echo check_address($input); Echo '<br><br>'; echo $input . " : " ; if(check_address($input) ) { echo('<br>This MX records exists; I will accept this email as valid.<br> '); } else { echo('<br>No MX record exists; Invalid email.<br>'); } echo '</center>'; ?> </html> I had it working without the form part so with a constant variable, but when I added the form it threw the error. I tried several options, but cant find the logic behind executing a good input without throwing an error and a bad domain giving this notice. Anyone any idea?