This topic is locked

insert data into another table not working

9/13/2008 12:49:50 AM
PHPRunner General questions
B
bochaka author

I want to send username and password to another table after successfull registration, however i cannot get it to work, Here is the custom code i am using

global $conn;

$strSQLInsert = "insert into `_clients` (`Clientid`, `clientpass`) values (`".$userdata["Username"]."`,`".$userdata["Password"]."`)";

db_exec($strSQLInsert,$conn);
It is based on the events template, am I using the correct array info for registration page of the template or have I some bogey code.

Sergey Kornilov admin 9/14/2008

Use single quotes (') to wrap text values instead of backticks (`).

Backtics are only to wrap field and table names in MySQL.

B
bochaka author 9/15/2008

Hi Jane,

I made the changes, but am getting the message
PHP error happened

Technical information

Error type 8

Error description Undefined variable: userdata

URL localhost/Events1/output/admin_users_add.php?

Error file D:\Program Files\PHPRunner4.2\projects\Events1\output\include\admin_users_events.php

Error line 25

SQL query insert into `_login`
Is .$userdata correct for adding users from the admin area, i am trying to add a new user from the admin area, not the usual register page.
my event code is added to the admin_users "before record added" page. I hope the syntax is correct, my code is below:

//** Custom code ****

// put your custom code here

$values["Password"] = md5($values["Password"]);
global $conn;

$strSQLInsert = "insert into `_userfeed` (`Usern`, `email`,`companyname`)

values ('".$userdata["Username"]."','".$userdata["email"]."','".$userdata["companyname"]."')";

db_exec($strSQLInsert,$conn);
return true;
// return true if you like to proceed with adding new record

// return false otherwise

J
Jane 9/16/2008

Hi,
there is no $userdata array in this event.

I suppose you need to use $values instead.