Topic: adding new field to user table (Read 556 times)
Raped By Google
Gender:
Posts: 27
206 credits Members referred : 0
PPC 4 Real Estate
« on: Feb 06, 2007, 07:28:35 AM »
I needed to add a new field to the user table that basically receives an affiliate ID number from a url variable. I've made a series of changes to access_user_class.php and to the register.php page as documented below. It seems to work without problem but I'm sure it can be dressed up but I thought I would pass on what I have done. The new value from the url variable is being inserted the databse at the registration.
Here are the changes I made.
I added a column to the table users (I happened to name it "upline_num" and it is in the sql statement below) and inserted a variable named "showcookie2" that I retrieve from the url. The line numbers are approximate as they change when lines are added.
On access_user_class.php I added
var $user_showcookie2; at line 79
Change line 638 (added $showcookie2 like this:
function register_user($showcookie2,$first_login, $first_password, $confirm_password, $first_name, $first_info, $first_email) {
Change line 659 (added db column name upline_num) like this: $sql = sprintf("INSERT INTO %s (id, upline_num, login, pw, real_name, extra_info, email, access_level, active) VALUES (NULL, %s, %s, %s, %s, %s, %s, %d, 'n')", (note that I also added another %s after values above to match the added parameter "upline_num")
Added line 662 $this->ins_string($showcookie2),
Then in register.php
I collect the showcookie2 value from the cookie and changed the line 22 (i.e. I added $_POST['showcookie2'],) like this $new_member->register_user($_POST['showcookie2'],$_POST['login'], $_POST['password'], $_POST['confirm'], $_POST['name'], $_POST['info'], $_POST['email']); // the register method
hope it helps!
« Last Edit: Feb 06, 2007, 07:41:11 AM by RealEstateAdvertis »
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6487
39754 credits Members referred : 374
It's time to use PHP5!
« Reply #1 on: Feb 06, 2007, 08:10:51 AM »
I don't suggest to add fields to the user table, use the profile table for additional information.