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


    Creating more info slots for Userinfo.php

    Share

    empecc

    Number of posts : 12
    Registration date : 2009-02-24

    Creating more info slots for Userinfo.php

    Post  empecc on Tue Feb 24, 2009 10:52 am

    I've readed some things on JP's main tutorial post, and there was lots of information about how to add more information into the userinfo.php.
    Suche as: age, country, sex (as in male or female), date of birth, ect.

    But I tried lots of things and couldnt it get to work.
    Does anyone have pre-made code for this?
    Or any tutorials for how-to's?


    Kinds regards,
    empecc
    avatar
    Linchpin311

    Number of posts : 220
    Age : 32
    Localisation : Long Island
    Registration date : 2007-05-14

    Re: Creating more info slots for Userinfo.php

    Post  Linchpin311 on Tue Feb 24, 2009 11:04 am

    i dont have anything already made on the subject cause the fields i tend to add (and the procedures for checking those fields) change often.

    More or less, the procedure goes like this:
    add new fields to database >
    add new fields to register.php >
    add code to check these fields in session.php >
    add code to display new fields in userinfo.php >
    add code to allow users to edit new fields in useredit.php >

    i know this is pretty vauge and it probably doesnt help all that much but if you PM me with what new fields you wanted to add i can walk you through it.

    Also i'll try writing up a ho-to on this topic in the next few days.


    _________________
    in the end, the universe tends to unfold as it should...

    Also note that it is your responsibility to die() if necessary.

    empecc

    Number of posts : 12
    Registration date : 2009-02-24

    Re: Creating more info slots for Userinfo.php

    Post  empecc on Tue Feb 24, 2009 11:26 am

    I'd rather like to post basic information here, so everyone can read it. Otherwise we will have more people asking about the same question:)
    Anyway, I'll try it and post it here.


    I want to add the following fields:

    <h1> User information </h1>

    Username (already present)
    Email (already present)
    Real Name.
    Date of birth. (Can be selected from a drop down menu)
    Country. (Can be selected from a drop down menu)
    Favorite Poker Room. (Drop down menu, two examples: PokerStars, PartyPoker.)


    <h1> Email settings </h1>

    Newsletter (checkbox)
    Hide email from public (checkbox)

    --------------------------------------------

    I'd like to post here all the information about WHERE to add those fields.
    And how to edit/add new MySQL fields, for this information.
    avatar
    Fred-Eric

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

    Re: Creating more info slots for Userinfo.php

    Post  Fred-Eric on Tue Feb 24, 2009 12:41 pm

    Linchpin311 wrote:Also i'll try writing up a ho-to on this topic in the next few days.

    Good idea !!!

    empecc

    Number of posts : 12
    Registration date : 2009-02-24

    Re: Creating more info slots for Userinfo.php

    Post  empecc on Tue Feb 24, 2009 1:20 pm

    I've tried to add some new fields

    1. MySQL Datebase (just added, so its at the buttom of the table)
    2. register.php
    3. process.php
    4. session.php
    5. database.php.
    6. useredit.php
    7. userinfo.php

    MySQL Database

    * username
    * password
    * userid
    * userlevel
    * email
    * timestamp
    * country


    Register.php

    Code:

    <tr>
      <td>
        <font id="bb">
               Username:
        </font>
      </td>
      <td>
        <input type="text" name="user" maxlength="30" value="
        <? echo $form->value("user"); ?>">
      </td>
      <td>
        <? echo $form->error("user"); ?>
      </td>
      <td>
        <font color="red">*</font>
      </td>
    </tr>
    <tr>
        <td>
          <font id="bb">
          Password:
          </font>
        </td>
        <td>
          <input type="password" name="pass" maxlength="30" value="
          <? echo $form->value("pass"); ?>">
        </td>
        <td>
       <? echo $form->error("pass"); ?>
        </td>
        <td>
          <font color="red">*</font>
        </td>                                 
    </tr>
    <tr>
        <td>
          <font id="bb">
           Email:
          </font>
        </td>
        <td>
          <input type="text" name="email" maxlength="50" value="
          <? echo $form->value("email"); ?>">
        </td>
        <td>
          <? echo $form->error("email"); ?>
        </td>
        <td>
          <font color="red">*</font>
        </td>                                 
    </tr>
    <tr>
        <td>
          <font id="bb">
           Country:
          </font>
      </td>
      <td>
          <input type="text" name="Country" maxlength="50" value="
          <? echo $form->value("country"); ?>">
      </td>
      <td>
            <? echo $form->error("country"); ?>
      </td>
    </tr>



    process.php

    Code:

    $retval = $session->register($_POST['user'], $_POST['pass'], $_POST['email'], $_POST['country']);




    session.php

    Code:

    function register($subuser, $subpass, $subemail, $country){

    and

    Code:

    if($database->addNewUser($subuser, md5($subpass), $subemail, $country)){



    database.php

    Code:

    function addNewUser($username, $password, $email, $country){

    and

    Code:

    $q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', $time, $country)";
          return mysql_query($q, $this->connection);



    userinfo.php

    Code:

    if($session->userlevel == 9){
    echo "<b>Username: ".$req_user_info['username']."</b><br>";
    echo "<b>Email:</b> ".$req_user_info['email']."<br>";
    echo "<b>Age:</b> ".$req_user_info['age']."<br>";
    echo "<b>Real name:</b> ".$req_user_info['realname']."<br>";
    echo "<b>Country:</b> ".$req_user_info['country']."<br>";
    echo "<b>Poker Room:</b> ".$req_user_info['poker_room']."<br>";
       }
    else
       {
    echo "<b>Username: ".$req_user_info['username']."</b><br>";
    echo "<b>Age:</b> ".$req_user_info['age']."<br>";
    echo "<b>Real name:</b> ".$req_user_info['realname']."<br>";
    echo "<b>Country:</b> ".$req_user_info['country']."<br>";
    echo "<b>Poker Room:</b> ".$req_user_info['poker_room']."<br>";
       }



    And finaly the useredit.php

    Code:

       <td>
          <input type="text" name="country" maxlength="50" value="
       <?
          if($form->value("country") == ""){
             echo $session->userinfo['country'];
                  }
               else
             {
             echo $form->value("country");
             }
          ?>">
       </td>
       <td>
          <?
                            echo $form->error("country");
                    ?>
       </td>



    As you can see, I didn't add the Age and Poker Room information/tables.
    Anyway, when I try to edit my country in my "account" I can type in "Netherlands" for example, but when I press "submit" I get this error.

    Code:

    Warning: Missing argument 4 for editaccount() in /blablabla/myhomepage/include/session.php on line 221

    Warning: Cannot modify header information - headers already sent by (output started at /blablabla/myhomepage/session.php:221) in /blablabla/myhomepage/process.php on line 119

    What did I do wrong?


    Last edited by empecc on Tue Feb 24, 2009 2:29 pm; edited 1 time in total
    avatar
    Linchpin311

    Number of posts : 220
    Age : 32
    Localisation : Long Island
    Registration date : 2007-05-14

    Re: Creating more info slots for Userinfo.php

    Post  Linchpin311 on Tue Feb 24, 2009 2:49 pm

    well im glad you tried to add fields one at a time, it certainly helps debug errors!

    did you update, editaccount() in session? i looks like you just edited the register function. i dont know why you are getting a headers sent error... hopefully that'll just go away when the other error is fixed.

    you might want to try removing any changes you made to useredit.php and userinfo.php and just making sure you can register with your new field first. i have had success adding all my new fields in register and making sure they can be added to the database first, then i go ahead and add the new code to userinfo and useredit. like i said, its best to take everything one step at a time.

    a few hours ago i had just restarted my macbook and was about to type this reply to you but my keyboard and trackpad decided not to function so i had to create a new partition on my hard drive and install os x to that. please bear with me while i get my life back online...


    _________________
    in the end, the universe tends to unfold as it should...

    Also note that it is your responsibility to die() if necessary.
    avatar
    Fred-Eric

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

    Re: Creating more info slots for Userinfo.php

    Post  Fred-Eric on Tue Feb 24, 2009 2:55 pm

    Linchpin311 wrote:...my keyboard and trackpad decided not to function so i had to create a new partition on my hard drive and install os x to that. please bear with me while i get my life back online...


    Twisted Evil Ho that bad.... Hope you will be resurected soon...

    empecc

    Number of posts : 12
    Registration date : 2009-02-24

    Re: Creating more info slots for Userinfo.php

    Post  empecc on Tue Feb 24, 2009 2:59 pm

    Oke, I made the script working without any errors.
    I added $country to the following files and sections.

    procEditAccount (inside process.php)
    editAccount (inside session.php)


    I debugged the error, however... when I add the country in useredit section (when logged in ofcourse) it accepts that I added it.
    But the country field is just empty, when I go to "userinfo.php?user=admin"

    empecc

    Number of posts : 12
    Registration date : 2009-02-24

    Re: Creating more info slots for Userinfo.php

    Post  empecc on Tue Feb 24, 2009 3:07 pm

    Oke, when I create a new account, and fill in "Country" field, it adds.
    But when I try to edit it, it doesnt work.

    empecc

    Number of posts : 12
    Registration date : 2009-02-24

    Re: Creating more info slots for Userinfo.php

    Post  empecc on Wed Feb 25, 2009 10:48 am


    empecc

    Number of posts : 12
    Registration date : 2009-02-24

    Re: Creating more info slots for Userinfo.php

    Post  empecc on Thu Feb 26, 2009 7:14 am

    Can anyone post here a good example of how to add new fields to registration AND how to add it for editing. And where to put the code, after what or before what code.
    Previouse posts on this forum didnt work. Tried it many times, and its frustrating!

    I like to add "country" in a drop down menu. (not neccesary to fill in)
    In registration and edit/info account information.

    Thanks in advance!
    avatar
    Admin
    Admin

    Number of posts : 18
    Registration date : 2007-05-12

    Re: Creating more info slots for Userinfo.php

    Post  Admin on Thu Feb 26, 2009 9:38 am

    This is a good guide for adding new field during the registration process.php
    http://jpmaster77forum.conceptbb.com/php-login-system-101-f2/adding-new-fields-part-1-t40.htm

    And this one for userinfo display and useredit display.
    http://jpmaster77forum.conceptbb.com/php-login-system-101-f2/adding-new-fields-part-2-t43.htm

    Sponsored content

    Re: Creating more info slots for Userinfo.php

    Post  Sponsored content


      Current date/time is Mon Nov 20, 2017 9:29 am