Search problem(value is store in reverse order)

i have two page one is search.php and other is detail.php
in search.php

 <div class="search-field ">
      <form class="d-flex align-items-center h-100" name="search" action="manage_visitor.php" method="post" >
        <div class="input-group" style="background-color: #f2edf3;">
          <input type="text" class="form-control bg-transparent border-0"name="searchdata" id="searchdata" placeholder="Search by names &amp; mobile no"   >
        </div>

Detail.php i get the value of there pagination code like

echo '<li class="'.$active.'" ><a class="page-link" href="manage_visitor.php?page1='.$i.'&searchname='.$_POST['searchdata'].'">'.$i.'</a></li>';

$searchstring= isset($_GET['searchname'] )?$_GET['searchname']:"";

for the first click the url look like

http://localhost/company/manage_visitor.php?page1=2&searchname=bilal

but after 2nd time click

http://localhost/company/manage_visitor.php?page1=2&searchname=

now is there way to store the value of searchname=bilal or set the value of search.php text field searchname value from detail.php

Problem in pagination when click any page

Three if condition
if(isset($_POST['search']) & !empty($_POST['searchdata']) )

if(isset($_POST['search']) & !empty($_POST['searchName']) )

Else
each statement have the own pagination created now confusion for example first condition is true and three page is created when i click its goes to else condition and below 10 pages is created which is true in else condition..how to handle the click of page to go to their respective condition