如何在按钮单击时重定向页面以及将数据保存在数据库中

When i click the save button after filling the form it should be saved in the database as well as should be redirected to the edit page where i can edit the fields.

The trick is to POST the form to the current page, save your data into the database using your favorite method and then redirecting to the next page.

Take a look at the following example:

<?php

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Insert into database
    $stmt = "INSERT INTO table (something) VALUES ('".$_POST['data']."')";

    // Redirect
    header("Location: nextpage.php");
    exit;
}
?>

<form action="<?= $_SERVER['PHP_SELF']; ?>" method="POST" role="form">
    <div>
        <label for="data">Your data to insert into the database</label>
        <input type="text" name="data" id="data" placeholder="Data to insert">
    </div>
    <button type="submit">Save</button>
</form>