View Full Version : How to insert a pre-defined number into user db
ChurchMedia
07-13-2007, 06:34 AM
Using the useradmin_edit_column2 and the userdata_start plugins, I need to insert 3 values into the user table. The trick is that 2 of them are input values and one of them is the same value as one of the input values. So like this:
$value_1 goes into field_1
$value_2 goes into field_2
$value_3 = $value_2
$value_3 goes into field_3
I know how to use input rows for the useradmin_edit_column2 hook, but I don't know what to use or how to format value 3 (which needs to be the same as value 2 and silently go into field 3). I've tried using standard PHP code, but it's not working. I think there's a vb class that I just don't know.
Any help would be appreciated. Thanks! :)
calorie
07-13-2007, 01:43 PM
One idea, assuming strings...
$db->query_write("INSERT INTO " . TABLE_PREFIX . "user
(field_1, field_2, field_3)
VALUES
(
'" . $db->escape_string($value_1) . "'
'" . $db->escape_string($value_2) . "'
'" . $db->escape_string($value_2) . "'
)
");
ragtek
07-13-2007, 01:58 PM
1. a plugin at hook: userdata_start
$this->validfields['myfield'] = array(TYPE_UINT, REQ_NO);
2. plugin useradmin_edit_column2
print_input_row($vbphrase['myuservalue1'], 'user[myfield]', $user['myfield'], 0);
ChurchMedia
07-13-2007, 06:13 PM
One idea, assuming strings...
$db->query_write("INSERT INTO " . TABLE_PREFIX . "user
(field_1, field_2, field_3)
VALUES
(
'" . $db->escape_string($value_1) . "'
'" . $db->escape_string($value_2) . "'
'" . $db->escape_string($value_2) . "'
)
");
I've tried sql queries and I tried this one too -- I get this error:
Fatal error: Call to a member function on a non-object in /path/to/me/CMN/includes/class_dm_user.php(183) : eval()'d code on line 1
1. a plugin at hook: userdata_start
$this->validfields['myfield'] = array(TYPE_UINT, REQ_NO);
2. plugin useradmin_edit_column2
print_input_row($vbphrase['myuservalue1'], 'user[myfield]', $user['myfield'], 0);
I was using this exactly for input fields and it works fine. I just need an "invisible" input row -- like the the HTML equivalent of a preset value in a form, but that value needs to be the same as my value 2.
calorie
07-13-2007, 06:15 PM
Perhaps try the construct_hidden_code function.
ragtek
07-13-2007, 06:31 PM
ups
I havent seen that you need a hidden row
look into adminfunktions.php
there you see all the functios available ;)
ChurchMedia
07-13-2007, 06:39 PM
Thanks -- I'll keep working on this and let you know what I find out. It's for a hack that I think a lot of people will like.
ragtek
07-13-2007, 06:40 PM
a "give me every month 1000$ on my konto" hack?
yea i'll love it
but i don't understand for what should be hidden fields used in this example
they can't do something usefull
ChurchMedia
07-13-2007, 06:54 PM
a "give me every month 1000$ on my konto" hack?
yea i'll love it
but i don't understand for what should be hidden fields used in this example
they can't do something usefull
Sarcasm aside....
I need to insert the same value from one input box into two database fields. I have my reasons -- I don't feel like explaining the whole hack. I can do this easily with regular sql queries, but with the hook system I'm having trouble (still learning). That's why I'm asking for help.
No biggie -- I'll figure it out eventually.
ragtek
07-13-2007, 06:57 PM
ok ok*g*
i'll see it after you publish it:D
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.