This topic is locked

Save id, username,password after login.

12/8/2006 1:36:47 PM
PHPRunner General questions
M
maxcolo author

Hi,

because this function not work after successful login:

function AfterSuccessfulLogin()

{

//** Insert a record into another table ****

global $conn;

$strSQLInsert = "insert into prova (id, username, password) values (".$values["id"].",".$values["username"].",".$values["password"].")";

db_exec($strSQLInsert,$conn);
}


New table is prova
field

id

username

password

Best regards

Max

Sergey Kornilov admin 12/8/2006

Max,
you miss single quotes around text values. Also you need to use BeforeLogin event because you have access to username and password in this event.

I assume ID field is autoincrement and don't need a value.

function BeforeLogin($username, $password)

{

global $conn;

$strSQLInsert = "insert into prova (username, password) values ('" . $username . "','" . $password "')";

db_exec($strSQLInsert,$conn);
return true;

}
M
maxcolo author 12/9/2006

Hi admin, tanks for your attention

No, I am badly perhaps me express.

I would like that after the recording I/you could save the data of id, username, password in two charts.
Table one

id autoincrement

username

Password
Table two

id (identical to that above)

username

password

........

.........

.........

........

..........

........

...............
Best regards

Max

Alexey admin 12/11/2006

Max,
I'm a quite confused with your messages.
What recording are you talking about ?

How this recording is related to Login page ?
Describe your task clearly and I'll try to help you.

M
maxcolo author 12/11/2006

Max,

I'm a quite confused with your messages.
What recording are you talking about ?

How this recording is related to Login page ?
Describe your task clearly and I'll try to help you.



Hi Alexey,

I try of spegarmi better but my English is insufficient and I pray you

to make excuses itself.

Which is the code to use for save (id,username,password) after login, in another table.

I need the function after login ad not before login, otherwise I do not have available the ID
Example:

function AfterSuccessfulLogin()

{

//** Insert a record into another table ****

global $conn;

$strSQLInsert = "insert into prova (id, nome, cognome) values ($id, $nome, $cognome)";

db_exec($strSQLInsert,$conn);
}

but Ihave this error:

Errore di tipo 8

Errore di descrizione Undefined variable: id

URL localhost/lavoro1/login.php?

Errore di file C:\WM\www\lavoro1\include\events.php

Errore di linea 7

Query SQL select * from `curricula` where `nome`='123456' and `cognome`='123456'


Best regards

Max

J
Jane 12/12/2006

Max,
here is a sample code:

function AfterSuccessfulLogin()

{

global $conn;
//select last inserted id from table1

$str = "select last_insert_id() from table1";

$rs = db_query($str,$conn);

$data = db_fetch_numarray($rs);
//select nome and cognome from table1

$str2 = "select nome, cognome from table1 where id=".$data[0];

$rs2 = db_query($str2,$conn);

$data2 = db_fetch_array($rs2);
$id = $data[0];

$nome = $data2["nome"];

$cognome = $data2["cognome"];
//insert id, name and cognome to the table2

$strSQLInsert = "insert into prova (id, nome, cognome) values ($id,'".$nome."','".$cognome."')";

db_exec($strSQLInsert,$conn);

}



where table1 and table2 are your actual table names.

M
maxcolo author 12/12/2006

Thank you so much, Jane
but this code dont' work , no error message but in the table "prova" no recorded, see the table database image:


Any idea the error code?

Max

J
Jane 12/13/2006

Max,
please post your table structure, full event code and detailed description of what you need to achieve here or send it to the [email=support@xlinesoft.com]support@xlinesoft.com[/email].