1

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.

bytecode77
  • 14,163
  • 30
  • 110
  • 141
freddy
  • 159
  • 1
  • 4
  • 23

1 Answers1

1

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.

David
  • 208,112
  • 36
  • 198
  • 279