DNS TXT record lookup

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
jmagn30
New php-forum User
New php-forum User
Posts: 1
Joined: Tue Mar 20, 2018 8:38 am

Tue Mar 20, 2018 8:46 am

Hey Everyone!

I am trying to verify users own a domain by adding in a TXT record on it, I have found quite a bit of code in PHP that allows for this, I am currently using this:

Code: Select all

$domain = $_POST['domain'];
$verify = $_POST['verify'];

	if(checkdnsrr("$domain","TXT")) {

		$result = dns_get_record("$domain",DNS_TXT);

		if (isset($result[0]["txt"]) && $result[0]["txt"] == $verify) {

		echo "Success!";
			
		}
	
	}
I am having a major issue though, because of the TTL (I am assuming), 9 out of 10 times it doesn't work, sometimes it can take hours before it does. I was using MX tools TXT lookup and they pull up the new TXT record in seconds, is there any way to get the TXT record immediately with PHP?

I am worried that it will take to long to get the users domain verified and they will forget or go somewhere else because of the delay.

Any help would be greatly appreciated!!

Post Reply