freddy
freddy

Reputation: 157

Get value of MySQL table right after form submitted

Is there a way to get the value of a MySQL table, right after the form has been submitted? In fact, with each new form submitted, there is a unique code posted in the table, but I need that code to rederict the user to a specefic URL, that contain the unique code.

Upvotes: 1

Views: 125

Answers (1)

David
David

Reputation: 219127

You can get the last MySQL-generated ID on the last inserted record by using last_insert_id(). More information here.

INSERT INTO SomeTable (SomeColumn) VALUES ('SomeValue');
SELECT LAST_INSERT_ID();

Depending on which data access method you're using there may even be a PHP-visible function to do this for you.

Upvotes: 1

Related Questions