KuJoe Posted February 2, 2010 Share Posted February 2, 2010 I am trying to create a custom hook to check the tblclients table when a client tries to register and check against the IP field to see if that IP is associated with an account already. My developer has been busy with non-work related things so I turn to you for some guidance. Here is the code I currently have which is a mash of examples I've found all over: <?php add_hook("ClientDetailsValidation",0,"checkIPIsValid",""); function checkIPIsValid($vars) { $regip = $_SERVER['REMOTE_ADDR']; $result = select_query("tblclients","id",array("ip"=>$regip)); while ($row = mysql_fetch_array($result)) { if ($regip = $result) { $errormessage .= "<li>This IP has already registered an account, please login to that account to place an order."; } } } ?> 0 Quote Link to comment Share on other sites More sharing options...
KuJoe Posted February 5, 2010 Author Share Posted February 5, 2010 Bump... 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted February 5, 2010 Share Posted February 5, 2010 Remember most clients would have dynamic IP's so it would change most of the time. This should work for you. <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); function checkIPIsValid($vars) { global $errormessage,$remote_ip; $result = select_query("tblclients","ip",array("ip"=>$remote_ip)); while ($row = mysql_fetch_array($result)) { if ($remote_ip = $row["ip"]) { $errormessage .= "<li>Your IP has already been used to register an account, please login to that account to place an order."; } } } add_hook("ClientDetailsValidation",0,"checkIPIsValid",""); ?> 0 Quote Link to comment Share on other sites More sharing options...
KuJoe Posted February 5, 2010 Author Share Posted February 5, 2010 Thanks! Works perfect! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.