Hey guys and gals,
I am fairly new to PHP, taught myself the basics for my company but struggling, so I used Usercake to create a secure login page as the one I wrote was terrible, SQL injections the works.
Now I am a little bit more experienced, but I am trying to set it so that the IP address can be used for verification, basically my boss only wants people to log in when they are on the specific IP address. We know the IP addresses will not change.
I know that
$ip=$_SERVER['REMOTE_ADDR'];
is probably the thing I need, the question is how I am to store it…
I have tried several times, but because I do it on usercake which I did not write, it seems to have a massive spaz.
Here is an example of the register script:
if (!empty($_POST)) {
$errors = array();
$email = trim($_POST["email"]);
$username = trim($_POST["username"]);
$displayname = trim($_POST["displayname"]);
$password = trim($_POST["password"]);
$confirm_pass = trim($_POST["passwordc"]);
$captcha = md5($_POST["captcha"]);
if ($captcha != $_SESSION['captcha']) {
$errors[] = lang("CAPTCHA_FAIL");
}
if (minMaxRange(5, 25, $username)) {
$errors[] = lang("ACCOUNT_USER_CHAR_LIMIT", array(
5,
25
));
}
if (!ctype_alnum($username)) {
$errors[] = lang("ACCOUNT_USER_INVALID_CHARACTERS");
}
if (minMaxRange(5, 25, $displayname)) {
$errors[] = lang("ACCOUNT_DISPLAY_CHAR_LIMIT", array(
5,
25
));
}
if (!ctype_alnum($displayname)) {
$errors[] = lang("ACCOUNT_DISPLAY_INVALID_CHARACTERS");
}
if (minMaxRange(8, 50, $password) && minMaxRange(8, 50, $confirm_pass)) {
$errors[] = lang("ACCOUNT_PASS_CHAR_LIMIT", array(
8,
50
));
and here is my sql table field…
13 ipaddress int(10) UNSIGNED Yes NULL
any help would be great please.