Jump to content

Limit 1 account per IP.


KuJoe

Recommended Posts

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.";
			}
		}
	}
?>

Link to comment
Share on other sites

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","");
?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated