We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30735
    • 18 Posts
    Hi

    I’m having issues getting a Domain Availability Checker script working in MODx. Does anyone have a script that works or would be able to modify this to work?
    <div class="subHead">Domain Purchase</div>
    <div class="padding">
    Check to see if the domain name you wish to purchase is available:
    <br />
    
    <? $d=str_replace(" ","",$_POST['domain']); ?>
    <form name="checkdomain" action="" method="POST">
    <input type="text" name="domain" size="27" value="<? print $d; ?>">
    <input type="submit" value="Check"><br />
    Ex: mydomain.com
    </form><br />
    
    <?
    if(isset($_POST['domain'])) {
    	ob_start();
    	@readfile("http://www.whois.net/whois.cgi2?d=".$d);
    	$content=strip_tags(ob_get_contents());
    	ob_end_clean();
    	if(strstr($content,"No match") || strstr($content,"Not found:")) {
    		$r='<span style="color:#00AA00;">Available</span>';$a=true;
    	} else if(strstr($content,"is registered") || strstr($content,"WHOIS information")) {
    		$r='<span style="color:#AA0000;">Registered</span>';
    	}  else {
    		$r='an <span style="color:#0000AA;">Invalid Domain</span>';
    	}
    print '<b>'.$_POST['domain'].' is '.$r.'!</b><br /><br />';
    }
    
    if($a) {
    ?>
    <div style="display:table;text-align:center;margin-left:10px;padding:4px;" class="subContent">
    <b>You can purchase it here:</b><br />
    paypal link
    </div><br /><br />
    <? } ?>
    
    
    </div>



    Any help would be welcome.
      • 27376
      • 576 Posts
      MODx Documents don’t support inline PHP. You will have to place all of your PHP code in a snippet.

      Could you briefly describe what the snippet is supposed to do, and what it currently is doing?
        • 30735
        • 18 Posts
        Its meant to check if the domain is available or not. Currently it will load the form but not process it.
          • 27376
          • 576 Posts
          Try calling the snippet [tt][!un-cached!][/tt] (as opposed to [tt][[Cached]][/tt]).