-1

I have my code below, I'm able to validate the domain but unable to validate the username even the domain name is valid.

For example:

mon@hotmail.com  --- valid domain valid username  ---- pass
aksjdsk@hotmail.com ----- valid domain invalid username  ---- failed

Appreciated if anyone can help.

function domain_exists($email, $record = 'MX'){
list($user, $domain) = preg_split('/@/', $email);
return checkdnsrr($domain, $record);}

if(!domain_exists($email)){
echo "<script type='text/javascript'>window.alert('No have such email,invalid Domain. please enter valid email address!')</script>";
echo "<script type='text/javascript'>window.location='register.html'</script>";
exit;}

function user_exists($email, $record = 'MX'){
list($user, $domain) = preg_split('/@/', $email);
return checkdnsrr($user, $record);}

if(!user_exists($email)){
echo "<script type='text/javascript'>window.alert('No have such user, please enter valid email address!')</script>";
echo "<script type='text/javascript'>window.location='register.html'</script>";
exit;}
Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680
Cally
  • 1
  • 2

2 Answers2

2

The only way to know is a particular username at a domain name exists, is to send them an email, and have them click a link that is provided in that email.

abuse@hotmail.com, x@x.org and obama@whitehouse.gov may well all be valid, doesn't mean that they requested the email, or care to use anything you might send.

Alister Bulman
  • 34,482
  • 9
  • 71
  • 110
1

Some sites send activation e-mail. Maybe you must use this.

generate an activation code for e-mail like this

<?php $activation_code= md5(microtime().rand(1,9999999)); echo$activation_code; ?>

and then register this code database with username's id or e-mail and send e-mail this code. if user don't click it in some time then delete the user or block..

josliber
  • 43,891
  • 12
  • 98
  • 133
BARIS KURT
  • 477
  • 4
  • 15