No content of created file

Discussion in 'PHP' started by nrodes, Nov 3, 2008.

  1. #1
    I'm making a "MySQL free" login script. After encoding the login info and checking it against pre-encoded info, my scripts suppose to make a file. Its suppose to be named the IP address of the user, and its suppose to contain the username of the user.

    It calls the file ".txt" instead of "76.114.191.116.txt" (76.114.191.116 is my ip address)


    Heres my script:

    <?php

    //get input data
    $user=$_POST["username"];
    $pass=$_POST["password"];

    //encrypt username and pass
    $cuser=md5($user);
    $cpass=md5($pass);

    //include login file
    include $user . ".php";

    //make sure info matches and changes user's logged in file to ip
    if ($cuser==$realuser && $cpass==$realpass)
    {
    $File = $REMOTE_ADDR . ".txt";
    $Handle = fopen($File, 'w');
    $Data = $user;
    fwrite($Handle, $Data);
    fclose($Handle);
    header( 'Location: main.php' );
    }
    else
    {
    echo "Your login info was incorrect. Please wait, Redirectin...";
    header ( 'location: index.htm' );
    }

    ?>



    Why is it doing this and how can i fix it???!!! :confused:
     
    nrodes, Nov 3, 2008 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    change
    $File = $REMOTE_ADDR . ".txt";
    //to
    $File = $_SERVER['REMOTE_ADDR'] . ".txt";
    PHP:
     
    JAY6390, Nov 3, 2008 IP
  3. nrodes

    nrodes Peon

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks. That fixed it :)
     
    nrodes, Nov 3, 2008 IP
  4. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #4
    cool:cool:
     
    JAY6390, Nov 3, 2008 IP