如果设置了日期,则根据日期显示数据库中的数据,否则显示页面加载和页面刷新的所有记录

I want to display records from database based on date if date is set else I want to display all records from table

sent_log.php

<form action="sent_log.php" method="POST">      
    <label>From</label>
    <input type="text" name="from_date">

    <label>To</label>
    <input type="text" name="to_date">  

<input type="submit" value="Submit" name="submit">
</form>

PHP Code

if(isset($_POST['submit']) && !empty($_POST['submit'])) {
    if (isset($_POST['from_date'],$_POST['to_date']) && !empty($_POST['from_date']) && !empty($_POST['to_date'])) {

    // code for display record based on date selected        

    }
} else {
   // code for display all records
}

SEE FULL CODE HERE Note: Don't consider the error in the link, Because code contains mysqli statements, I just want to display code not to display output, The code working fine without any error in my local pc!

Now my problem is when I open sent_log.php following code block working fine

else {
       // code for display all records
}

And when I select 2 dates and hit submit button, the following code block working fine

 if(isset($_POST['submit']) && !empty($_POST['submit'])) {
    if (isset($_POST['from_date'],$_POST['to_date']) && !empty($_POST['from_date']) && !empty($_POST['to_date'])) {

    // code for display record based on date selected        

    }
} 

But when I refresh the page I want to display all records But Now the output not changed, It displays records based on dates I selected Last time

I am looking output like

Display All records when first time load sent_log.php and when I refresh sent_log.php

If I select 2 dates from form in sent_log.php, load records based on 2 dates then I click refresh button load all records

From the Internet, To avoid form resubmission, It will be achieve By using 3 methods: Redirect to self, Ajax, session

But I don't know how to apply these 3 methods to my case