SamDOD Posted October 16, 2008 Share Posted October 16, 2008 I am wanting to add each users IP address into the database along side each users name. I have this code so far that gets the IP address and adds it into the database. I am not sure how to tell it to add the IP address for each user that is loged in. <?php include("adminpro_config.php"); include("adminpro_class.php"); include("adminuser_config.php"); $servername=$globalConfig['dbhost']; $dbusername=$globalConfig['dbuser']; $dbpassword=$globalConfig['dbpass']; $dbname=$globalConfig['dbase']; connecttodb($servername,$dbname,$dbusername,$dbpassword); function connecttodb($servername,$dbname,$dbuser,$dbpassword) { global $link; $link=mysql_connect ("$servername","$dbuser","$dbpassword"); if(!$link){die("Could not connect to MySQL");} mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error()); } $ip=@$REMOTE_ADDR; $strSQL= "INSERT INTO myuser(ip) VALUES ('$ip')"; $test=mysql_query($strSQL); $prot=new protect("1","1"); if ($prot->showPage) { $db=new mysql_dialog("1"); $db->connect($globalConfig['dbhost'],$globalConfig['dbuser'], $globalConfig['dbpass'], $globalConfig['dbase']); $SQL="SELECT ".$globalConfig['tblUserName']." as userName, "; $SQL.=$globalConfig['tblIsAdmin']." as isAdmin"; $SQL.=" FROM ".$globalConfig['tbl']; $db->speak($SQL); $option=""; //for the select tag normal users $optionad=""; //for the select tag admins $action=""; //main navigation $editName=""; $userName=""; $allusers=0; //count all normal users $alladmins=0; //count all admins while ($data=$db->listen()){ $option.="<option value=\"".$data['userName']."\">".$data['userName']; if ($data['isAdmin']==1){ $alladmins++; } else{ $allusers++; } } extract($_POST); ?> the first connection at the top is the one i am concered with. The econd works as it should. I know it there is a way to tell it to insert the IP addres into the user who is loged in but how. Please Help thank you! Quote Link to comment https://forums.phpfreaks.com/topic/128650-php-mysql-insert-into-a-feild/ Share on other sites More sharing options...
fenway Posted October 16, 2008 Share Posted October 16, 2008 Where's the authentication code? Quote Link to comment https://forums.phpfreaks.com/topic/128650-php-mysql-insert-into-a-feild/#findComment-667127 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.