I have 3 PHP pages:

**form.php:** 

It is a form page to get details from the user and submit to input.php.

**input.php:**

It is a backend PHP page where the posted vars from form.php will be inserted into the database.

**index.php:**

It is the main page where the data saved in the database is shown in a table.,

Now the problem is: 

When I submit the form.php it redirects to input.php where the posted data is stored in DB and then redirects to index.php. 
But when the index.php page opens, it won't show the recently uploaded data through input.php until I refresh the page.

My code goes as:

**form.php:**

```
<form class="form-horizontal tasi-form" method="post" id="adddelete" action="input.php">
    <input type="hidden" name="id" form="adddelete" value="<?php echo ($row2["id"]); ?>"/>
     <div class="panel-body">                                  
         <div class="form-group">
             <label class="col-sm-2 col-sm-2 control-label">Name : </label>
                <label><input type="text" name="name" style="width:200px;"/></label>
         </div>                               
     </div>
    <div class="panel-body">                                  
         <div class="form-group">
             <label class="col-sm-2 col-sm-2 control-label">Price : </label>
             <label><input type="number" name="price" style="width:200px;"/></label>
         </div>                               
    </div>
    <div class="panel-body">                                  
             <div class="form-group">
                  <label class="col-sm-2 col-sm-2 control-label">Category : </label>
                   <label ><select name="category" style="width:200px; height:30px;">
                            <option value="egglesscakes">Eggless Cakes</option>
                            <option value="photocakes">Photo Cakes</option>
                            <option value="cupcakes">Cup Cakes</option>
                            <option value="sugerlesscakes">Sugerless Cakes</option>
                            <option value="cheesecakes">Cheese Cakes</option>
                            <option value="premiumcakes">Premium Cakes</option>
                            <option value="tiercakes">Tier Cakes</option>
                            <option value="barbiecakes">Barbie Cakes</option>
                            <option value="kidscakes">KLids Cakes</option>
                            <option value="cartooncakes">Cartoon Cakes</option>
                            <option value="birthdaycakes">Birthday Cakes</option>
                           </select>
                    </label>
                </div>                                
            </div>
            <div class="panel-body">                                  
                <div class="form-group">
                     <label class="col-sm-2 col-sm-2 control-label">Description : </label>
                      <label><textarea type="text" name="description" placeholder="Description" style="width:300px; height:100px;"></textarea></label>
                </div>                                
           </div>

            <button class="userprofiledelete" form="adddelete" type="submit" align="center"> ADD </button>
</form>

```

**input.php:**

```
<?php include('index.php'); ?>

<?php

$servername  = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "databasename";

$name = $_POST['name'];
$price = $_POST['price'];

$category = $_POST['category'];
$description = $_POST['description'];

$date = date_default_timezone_set('Asia/Kolkata');
$date = date('M-d,Y H:i:s');
$date2 = date('M-d,Y');

$conn = new mysqli ($servername, $dbusername, $dbpassword, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO cakes (name, price, category, description, date2)
VALUES ('$name', '$price', '$category', '$description', '$date2')";

if ($conn->query($sql) === TRUE) {
echo '<script language="javascript">';
echo 'alert("You have succesfully updated product")';
echo '</script>';
echo '<a href="index.php"></a>';
}
else {
    echo "ERROR" . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

```

**index.php:**

```
<table class="table table-hover" >
<tr>
<th>Name</th>
<th>Price</th>
<th>Category</th>
<th>Added At</th>
<th></th>
</tr>
<?php 
    $sql2 = "SELECT * FROM cakes ORDER BY date2 DESC";
    $result2 = $conn->query($sql2);
    if ($result2->num_rows > 0) {                               
while($row2 = $result2->fetch_assoc()) {                                   
?>

<tr >
      <td><a href='acakessub.php?id=<?php echo $row2['id'];?>'><?php echo ($row2["name"]); ?></a></td>
      <td><a href='acakessub.php?id=<?php echo $row2['id'];?>'><?php echo ($row2["price"]); ?></a></td>
      <td><a href='acakessub.php?id=<?php echo $row2['id'];?>'><?php echo ($row2["category"]); ?></a></td>
     <td><a href='acakessub.php?id=<?php echo $row2['id'];?>'><?php echo ($row2["date2"]); ?></a></td>                                                  
</tr> 

<?php     }
         } else {
    echo "0 results";
    }
?>
</table>

```

Hope I'm clear with my problem. Please Let me know if I'm not clear.
Any help is appreciated.