Messaging system

Hello. I am working on a messaging system. I have two form fields. name & message.

this is my database.

id | user
1 Jacob
2 Billy
3 Peter

id_to | id_from | message

When I enter ‘Jacob’ into my name field, how do I insert the ID associated with him in the MESSAGES(id_to) table?

do a lookup on the users table

How do I perform a ‘lookup’ ?

  FROM users
 WHERE name = 'jacob'

Hi, thank you for your response.

How do I insert the id that is retrieved using the look up into my messages table?

And you can definitely be sure that there will never be two people with the same name in your database, can you? Never two people called dr john for example?

If you can be sure that this is a unique user name, then the user is your primary key and you do not need to use an id.

Re inserting the id into your other table - use queries to find the ids, use php to assign them to variables which then get inserted into another query which php will then run to insert into the messages table.