vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Registration fields INSERT into another dbase also? (https://vborg.vbsupport.ru/showthread.php?t=142409)

Jim Nayzium 03-18-2007 02:01 PM

Registration fields INSERT into another dbase also?
 
I would like for my custom fields that I have added through the admin cp to INSERT into my custom database upon registration.

I have successfully hacked into the register.php and the functions_login.php to get it all to work on the 'pre-defined' fields...but the custom fields seems to have an array code that is over my head.

Basically, I have only added firstname and lastname fields, and I have another table in my database that is customized to use for my classifieds section, which is running a different custom software.

I am able to INSERT the username and password just fine tapping into the vBullein->userinfo stuff...and the GPC array.

However, my problem is it seems like the custom stuff is all inserted into one array and then that full array is inserted into the vb_ table all at once...

I know how to summon on row of an array using array['desiredinfo'] syntax...

but what if the desiredinfo is an array ??

seems like I want something like

array['desiredinfoArray']['desired_info_inside_this_array']

OR alternatively -- can someone just give me the best way to have the registration custom added fields be INSERTed into the vb database, AND into another database upon registration....

thanks.

Flexserve 03-20-2007 01:07 AM

I need to know this also. No one on forums seems to know how, it's been asked several times.:confused:

Jim Nayzium 03-20-2007 01:29 AM

Well, I just finally solved this on my own.

I am so used to the phpBB open source world where every user is so helpful and everyone works so well together....

the catch is they NEED to be, cuz the software requires all that help...hahaha.

I love this vBulletin deal --- MUCHO....

$vbulletin->GPC['userfield']["field5"]
$vbulletin->GPC['userfield']["field6"]

are the values you need to insert for your custom fields...assuming these are the first two cusstom fields you added....

for me it was 5 -= first name and 6 =- last name

and I inserted them into another database table upon regisration....so they hit userfield5 and 6 in the vb_userfield tables....or usertext not sure which....

and they also hit my database table


PHP Code:

$insertSQL sprintf("INSERT INTO table_name (firstname, lastname) VALUES (%s, %s)",
GetSQLValueString($vbulletin->GPC['userfield']["field5"], "text"),
GetSQLValueString($vbulletin->GPC['userfield']["field6"], "text")); 

Of course GetSQLValueString is a dreamweaver code inserted when you insert your recordset to begin with...

Flexserve 03-20-2007 04:53 PM

Can you explain where to put this??

Sorry, new to vbulletin ways of doing things and this is something I need to do asap.

Thanks in advance:D

Jim Nayzium 03-20-2007 06:56 PM

register.php starting around line 307

PHP Code:

$class mysql_pconnect('IP_ADDRESS_DBASE_HERE''DBASE_USER>HERE''DBASE_Password_HERE') or trigger_error(mysql_error(),E_USER_ERROR); 

//This is auto-created by DREAMWEAVER when you do a recordset.
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
//Here is the good part....
$insertSQL sprintf("INSERT INTO class_users (username, password, email, firstname, lastname) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($vbulletin->GPC['username'], "text"),
GetSQLValueString($vbulletin->GPC['password_md5'], "text"),
GetSQLValueString($vbulletin->GPC['email'], "text"),
GetSQLValueString($vbulletin->GPC['userfield']["field5"], "text"),
GetSQLValueString($vbulletin->GPC['userfield']["field6"], "text"));
mysql_select_db('DBASE-NAME-HERE-AGAIN'$class);
$Result1 mysql_query($insertSQL$class) or die(mysql_error()); 

My $class file is obviously my connection to my database....
Hope you understand the sprintf php command - if not do a google for sprintf and php....

MarkPW 03-20-2007 07:13 PM

There is no need to modify vbulletin's files to achieve this. vB have a hook system of which allows you to execute external code at many different locations within vB's files, such as the registration or activation process.

See: What is a hook?

With regard to adding custom fields to a seperate db table upon registration - all you need to do is add a plug-in at the correct hook location (via the AdminCP), and include the code you wish to run. In this instance, you would add a hook at the following location: "register_addmember_complete" and include the database code you wish to run.

Similarly, if you only want to copy user details upon activation, you would use the hook, "register_activate_process".

Hope this helps!

Jim Nayzium 03-20-2007 07:19 PM

DUDE --- WHERE HAVE YOU BEEN!!!! This is great information....I am so used to OSCommerce and phpBB -- just hacking away at the actual code ---

MarkPW's way sounds much much better!!!

MarkPW 03-20-2007 07:36 PM

No problem ;)

Jim Nayzium 03-20-2007 07:47 PM

1 Attachment(s)
One more quick one -- this has revolutionized my thinking, but I cannot quite wrap my head around it....

So I go to Add New Plugin---

and insert my custom php code in that box on that screen, and toggle the drop down to the location I want....and that is it??

Do I need to add a product or anything like that?

I am thinking I am going to remove all my customizations from the register.php and the functions_login.php files and put them in hooks so I can upgrade easier...

But I am not quite comprehending the whole process. I think it is so simple, I am just having a hard time believing it.

I attached a pdf screen grab of the page I am talking about.

No chance you could just walk me through a very simple one from start to finish...

something like, add this 123TEXT to this HOOK location and then watch the page refresh and see your text....

REALLY appreciate....

Flexserve 03-20-2007 08:37 PM

Please do tell..we (a group) are trying to accomplish this very task.


All times are GMT. The time now is 07:12 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01372 seconds
  • Memory Usage 1,765KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete