As the title says it all, how do I add their IP addresses to my SQL database while they are registering. I'm hosting a game server to track which ID is on which IP.
<?php
if($_POST['B1'])
{
mysql_select_db($mydbacc);
$userid = trim($_POST['id']);
$password=trim($_POST['pass']);
$passretype=trim($_POST['retpass']);
$hash=$_POST['hash'];
if($password != $passretype) {
echo "Password not equal to Retyped Password.";
}else{
if(!ereg("^[0-9a-zA-Z]{4,12}$",$password))
{
echo "Only letters or numbers, length of 4 to 12 characters";
}
else
{
$res = mysql_query("select * from account where name = '".$userid."' order by id desc");
if(mysql_num_rows($res) == 0)
{
mysql_query("insert into account (name,Password,Reg_date) values ('".$userid."','".$hash."','".date("y-m-d H:i:s", time())."')");
echo "Account registered successfully.";
}
else
{
echo "Account Already exists in database.";
}
}
}
}
?>
This is the code where users use to register an account, is there any code to put in between somewhere that it can save their IP addresses on IP table?
Thanks!