$db->query("INSERT into `users` (username, password, email)
VALUES ('$username', '$hashpassword', '$email')");
$userid = mysqli_insert_id($db->link);
$db->query("INSERT into `users logins` (userid, token, ip)
VALUES ('$userid', '$token', '$ip')");
The above is old code. The below is my new:
$db->query("BEGIN TRANSACTION;
INSERT into `users` (username, password, email)
VALUES ('$username', '$hashpassword', '$email');
[here I need to get the row ID of the above insert]
INSERT into `users logins` (userid, token, ip)
VALUES ('$userid', '$token', '$ip')
COMMIT;");
How can I grab the first insert row ID and use it for the second insert?
use
LAST_INSERT_ID()or how about creating
Stored Procedure