Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    New game.. One problem..Help?

    Alright, here's the code.. and what i know i need..

    include('lib.php');
    if (isset($_GET["do"])) {
    if ($_GET["do"] == "login") { login(); }
    elseif ($_GET["do"] == "logout") { logout(); }
    }

    function login() {

    include('config.php');
    $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");
    die();

    }

    $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");
    die();

    }

    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");

    $last=0;
    $next=1;

    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];
    $found=1;
    }
    }
    if(!$found) {
    echo $next;
    $IP[$last][0]=$user[ip];
    $IP[$last][1]=$next;
    $last++;
    $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

    $ip=$userrow[ip]????

    Anyone got any idea's?

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

  • #2
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •