Re: Edit an existing record and save it as a new record
This form will have only this button? Or the others button will be available too?
You can create a new button called Duplicate(for example) of the type PHP …
if you a running under MySQL, you php code will be:
//if your fields is auto increment, otherwise you need to fill the primary key
sc_exec_sql(“INSERT table (field1, field2…) SELECT field1, field2 FROM table where key = ‘{key_field}’”);
//to get the last inserted key, if is mysql and if is auto increment
sc_lookup(rs, “SELECT LAST_INSERT_ID()”);
//now you can redir again to the form, opening in the new record
sc_redir("…/your_own_form/your_own_form.php?your_primary_key_field=" . {rs[0][0]} . “”);