I have a message table
**message**
msg_id (AI) | user_id | content
and user table
**user**
user_id (AI) | email | password | name
I would like to save the user who posted the message in the database. The codes I wrote allow me to save a message sent to the database but notuser_id
if (isset($_POST['submit'])) {
$msg = new msg();
$msg->user_id = ???
$msg->content = trim($_POST['content']);
if ($msg->createMsg()) {
} else {
}
createMsg() is the sql statement that inserts my query.
How do I get user_idfrom a table userto be stored in a table message?
source
share