/    Sign up×
Community /Pin to ProfileBookmark

Query Questions. O.o

[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;
}
?>[/code]

[/B][/COLOR][/SIZE][/FONT]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @TehShlocker spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...