Jump to content
MakeWebGames

Recommended Posts

Posted

What do you define as being "safe and perfect"? There are a number of ways you can check the IP, but not sure what you're trying to achieve.

Posted

i wanna save ip in database by number format ,can suggest me string is better way or number ?

like this

function vaild_ip($ip)

{

$ip = trim($ip);

if (filter_var($ip, FILTER_VALIDATE_IP)) {

$ip = sprintf('%d', ip2long($ip));

return $ip;

}

}

$ip = vaild_ip($_SERVER['REMOTE_ADDR']);

Posted

filter validate IP validates the IP

 

Returns the filtered data, or FALSE if the filter fails.

So if it's false the IP is malformed/malicious.

It has to be a string as a number wouldn't allow dots (.) I think

EDIT: Dave beat me >.<

Posted
filter validate IP validates the IP

 

So if it's false the IP is malformed/malicious.

It has to be a string as a number wouldn't allow dots (.) I think

EDIT: Dave beat me >.<

check this function please ip2long

Posted
check this function please ip2long

What do you mean check this function?

Posted
i am using PDO then ?

http://www.php.net/manual/en/intro.pdo.php

PDO provides a data-access abstraction layer, which means that, regardless of which database you're using, you use the same functions to issue queries and fetch data. PDO does not provide a database abstraction; it doesn't rewrite SQL or emulate missing features. You should use a full-blown abstraction layer if you need that facility.

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.

×
×
  • Create New...