返回更改表单时如何更新数据库? [关闭]

I have a form that sends data to the database after sending data it redirect me to a page with go back button and an Edit button, am using php and i want to edit the row that i just added, can you help me ?

Pass newly inserted row's id on the go back and edit button click function. And in the first form set a hidden field like hiddenId with this parameter. On submission check for the hiddenId value. If it is set perform UPDATE action otherwise INSERT.

**firstform.php**

<form action="secondform.php" method="POST"> 
<input type="hidden" name="hiddenId" value = "<?php echo @$newlyInsertedId ;?>">
.
.
.
</form>

**secondform.php**

<form action="otherform.php" method="POST"> 

<input type="button" onclick ="retFirst('$newlyInsertedId');" />
</form>

<script>

function retFirst(newlyInsertedId){
window.location.href = "firstform.php?newlyInsertedId="+newlyInsertedId+"otheroarams"

}
</script>

When you will go to the second page after inserting data from the first page, pass the id of the last inserted data to the second page via url.

From the second page when click on the go back button, set the url along with the id so that you can get the id on the first page.

On the first page load, check if there any id in the url. If it is there , fire a select query using that id and fill the form elements and keep update button otherwise keep form elements blank and fire the insert query on submit.