PHP Login System with Admin Features

This forum was created to talk about the PHP Login System with admin features created by jpmaster77 on evolt's website


    ip loging/banning system

    Share
    avatar
    salfordscripteR

    Number of posts : 3
    Age : 30
    Registration date : 2009-03-10

    ip loging/banning system

    Post  salfordscripteR on Tue Mar 10, 2009 8:34 pm

    hi, im trying to find a way, of logging peoples ip address in the database with the users details,
    my idea is to, inlude something in the registration page to record the ip with the rest of the user info submited to the database, and then incluse something in the login page which updates the ip address when a user logs in, any help would be of great value to me and many other


    thanks
    avatar
    salfordscripteR

    Number of posts : 3
    Age : 30
    Registration date : 2009-03-10

    progress

    Post  salfordscripteR on Wed Mar 11, 2009 4:09 am

    hi guys, iwoke up this morning and thoght id give this ip thing a go my self, so far ive managed to make a function to log the ip address of the person registering, thanks to Fred-Eric's adding new feilds TUT, this is what ive got so far:

    ------------------------------------------------------------------------------
    1- Altering the sql table

    Code:

    ALTER TABLE `users` ADD `ip` char(50) NOT NULL ;

    --------------------------------------------------------------
    2- Edit register.php and add the new control input element into the form.

    Code:

    <!-- this is the new part -->
    <tr>
    <td>ip:</td>
    <td><input type="hidden" name="ip" maxlength="32" value="<?php echo $_SERVER["REMOTE_ADDR"]; ?><? echo $form->value("ip"); ?>"></td>
    <td><? echo $form->error("ip"); ?></td>
    </tr>
    <!-- end new part -->
    -----------------------------------------------------------------------------------
    3- Edit process.php and find the function call procRegister().
    Add the posted value $_POST[ip] as a new argument to the $session->register($_POST['user'], $_POST['pass'], $_POST['email'], $_POST['ip']);.

    Code:

    /* Registration attempt */
    $retval = $session->register($_POST['user'], $_POST['pass'], $_POST['email'], $_POST['ip']);
    -----------------------------------------------------------------------------------
    4- Edit session.php and find the function call register()
    Make sure to add the new $argument to that function

    Code:

    function register($subuser, $subpass, $subemail, $subip){
    -----------------------------------------------------------------------------------
    4.2- Then, if no error is found in the form you will send the info to the DB using $database->addnewuser() class function.

    Code:

    $database->addNewUser($subuser, md5($subpass), $subemail, $subiip))
    -----------------------------------------------------------------------------------
    5- Edit database.php and find the function call addNewUser.

    Code:

    /**
        * addNewUser - Inserts the given (username, password, email)
        * info into the database. Appropriate user level is set.
        * Returns true on success, false otherwise.
        */
      function addNewUser($username, $password, $email, $ip){
          $time = time();
          /* If admin sign up, give admin user level */
          if(strcasecmp($username, ADMIN_NAME) == 0){
            $ulevel = ADMIN_LEVEL;
          }else{
            $ulevel = USER_LEVEL;
          }
          $q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', $time, '$ip')";
          return mysql_query($q, $this->connection);
      }
    -----------------------------------------------------------------------------------
    so there it is, the first part of the ip system, i will work on it abit more, and if anyone has any idea's or can make this better, please post let s know,

    thanks
    salfordscripteR


    EDIT-sorry for the bad post am new to this site, not sre ho todo things yet, but get the idea of the post(erm.....hopefuly Very Happy )
    avatar
    Fred-Eric

    Number of posts : 63
    Registration date : 2007-05-13

    Re: ip loging/banning system

    Post  Fred-Eric on Wed Mar 11, 2009 6:39 am

    Nice work, but in the register.php you don't need to echo the form value and the form error, because it is a hidden field and no user need's to see that.

    Code:

    <!-- this is the new part -->
    <tr>
    <td>ip:</td>
    <td><input type="hidden" name="ip" maxlength="32" value="<?php echo $_SERVER["REMOTE_ADDR"];?>"></td>
    </tr>
    <!-- end new part -->


    _________________
    Appologize for my bad english, I am speaking french.
    ------------------------------------
    Visit my blog: How To Make a Login System for Your Website
    avatar
    salfordscripteR

    Number of posts : 3
    Age : 30
    Registration date : 2009-03-10

    Re: ip loging/banning system

    Post  salfordscripteR on Wed Mar 11, 2009 2:22 pm

    thats what i thought but when i removed echo, it wouldnt record the ip, but so far hat ive used seems to work, and the user doesnt see the ip, because the hidden form hides it, if u wish to play with it and tidy it up, be my guest lol.

    im working on the login page at the moment, making a update ip function, i will proberly mess arond with the code when i know it all works Very Happy Very Happy Very Happy
    avatar
    intothefantasy

    Number of posts : 37
    Registration date : 2009-04-11

    Re: ip loging/banning system

    Post  intothefantasy on Sun Apr 12, 2009 1:18 am

    hmm how do u ban user from their ip instead of username then?

    Sponsored content

    Re: ip loging/banning system

    Post  Sponsored content


      Current date/time is Tue Oct 23, 2018 9:34 am