View Full Version : New game.. One problem..Help?

03-24-2007, 04:50 AM
Alright, here's the code.. and what i know i need..

if (isset($_GET["do"])) {
if ($_GET["do"] == "login") { login(); }
elseif ($_GET["do"] == "logout") { logout(); }

function login() {

$link = opendb();

if (isset($_POST["submit"])) {

$query = doquery("SELECT * FROM {{table}} WHERE username='".$_POST["username"]."' AND password='".md5($_POST["password"])."' LIMIT 1", "users");
if (mysql_num_rows($query) != 1) { die("Invalid username or password. Please go back and try again."); }
$row = mysql_fetch_array($query);
if (isset($_POST["rememberme"])) { $expiretime = time()+31536000; $rememberme = 1; } else { $expiretime = 0; $rememberme = 0; }
$cookie = $row["id"] . " " . $row["username"] . " " . md5($row["password"] . "--" . $dbsettings["secretword"]) . " " . $rememberme;
setcookie("dkgame", $cookie, $expiretime, "/", "", 0);
header("Location: index.php");


$page = gettemplate("login");
$title = "Log In";
display($page, $title, false, false, false, false);


function logout() {

setcookie("dkgame", "", time()-100000, "/", "", 0);
header("Location: login.php?do=login");


Minus the php tags.

Now..heres what i need to add, i've pretty much figured this part out..

Before the Header(index.php)
Now.. everytime a SQL query is made..its in the form.. DOQUERY.. Using MYSQL breaks the page, or, the game.
mysql_query("UPDATE user SET ip='".getenv('REMOTE_ADDR')."' WHERE username='".$_POST["username"]."' AND password='".md5($_POST["password"])."' LIMIT 1", "users"

$users=mysql_query("SELECT * FROM user");


while($user=mysql_fetch_array($users)) {

for($i=0;$i [less-than] $last && !$found;$i++) {
if($player[ip]==$IP[$i][0]) {
echo $IP[$i][1];
if(!$found) {
echo $next;
and that..

NOW.. Do i need to put that last part in the Index(header)
..or in the member list(where im wanting to View everyones IP.)

Also there is a $userrow[ip] <--Database on all users.

But i cant seem to get it to Post their IP's there.

then i could just easly do


Anyone got any idea's?

I've spent 3 full days of coding trying to get this working.

03-24-2007, 05:53 AM
Wow... I'm not sure I completely follow. Are you just trying to query the database and display all the users IP's? Where did the $player variable come from? Where did this $IP array come from?

Also wrap your php code in php bbcode tags. [ php ] code here [ /php ] Minus the spaces between the brackets.

03-24-2007, 09:44 AM
Im trying to Query the DB and List all the IP's of All users(When they login it changes, just incase they ever change, like..auto update)
Onto my members page.

I need to set their IP's(on login set IP MySQL..Set.. $userrow[ip]

And display using a variable $ip