Logic behind back button

i’m making a project in which i have to put back button functionality. and i cant seem to work it out. I have created a back button and it works. but if the user wants to edit the previous form and then submit, so it edits the query. i have tried it in my project but it adds another record in the database and doesn’t update the previous one..i know im not using any update query here..coz i am confuse that how would it works..i cant think of a good logic..I have made a simple form for practice.. it is written below..And thanks for your expert advice in advance…

     php file

       $sql="INSERT INTO `tbl`(`first_name`, `last_name`) VALUES                 
       $run=mysqli_query($con, $sql);

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"                 
          <html xmlns="http://www.w3.org/1999/xhtml">
         <meta http-equiv="Content-Type" content="text/html; charset=utf-8"                    
        <title>Untitled Document</title>

         <form method="POST" action="nextpage.php">
      First_name:<input type="text" name="fname">
        Second_name:<input type="text" name="lname">
       <input type="submit" name="sub" value="submit">




      <h1>Next Page</h1>
       <p>The query is submitted press ok to forward and back if you want to 
     go back</p>
        <button >OK</button>
      <button onclick="history.go(-1);">Back</button>

Source: jquery

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.