[FONT=Times New Roman][SIZE=3][COLOR=Blue][B]
Okay.. I’ve been programming in PHP with MySQL for about 26 hours now, and I’ve ran into a bunch of problems, however each time YOU GUYS were there to help me. No matter how hard the situation was ya’ll help, so here:
I need to be able to log the client pc’s ip adress so that I can store it into their row of the members table. That way evertime my site is visited it checks the clients pc for the ip address and checks to see if the members ip corresponds with that from the one in the table from earlier, thus they’re logged in. (I know it’s proly a paradox way of doing things, and if anyone knows a better way to log whether or not the client is logged in or not, PLEASE TELL ME.) anyways here’s what I’ve got:
[code=php]<?php
//Set variables
$Pswd=$_POST[“Pswd”];
$Mebr=$_POST[“Mebr”]; $Mebr = strtolower($Mebr);
$hostname=”mysql141.secureserver.net”;
$username=”TehShlocker”; $passwrd=”*****”;
$dbname=”TehShlocker”; $tbname=”members”;
$query=”SELECT Password, MemberName FROM members WHERE MemberName = ‘$Mebr’ and Password = ‘$Pswd'”;
//Connect to Database
mysql_connect($hostname,$username, $passwrd) OR DIE (“Unable to connect to database! Please try again later.”);
mysql_select_db($dbname) OR DIE (“Unable to select to Database! Please try again later.”);
$result = mysql_query($query) OR DIE (mysql_error());
$num_rows = mysql_num_rows($result);
if ($num_rows == “1”) {
echo “<center><b>Thank you for logging in $Mebr </b><br>”;
echo “You will be redirected in 5 seconds<br>”;
echo “Thank you for your Patience<br>”;
$sql = ‘UPDATE `members` SET `Online` = ‘yes’, `ip` = ‘$REMOTE_ADDR’, `lastvisit` = NOW() WHERE `MemberName` = ‘$Mebr’ LIMIT 1;’;
mysql_query($sql) OR DIE (mysql_error());
echo $REMOTE_ADDR;
}
?>
[/B][/COLOR][/SIZE][/FONT]