Create a text field by the name of val inside the form on index file eg:
<form action="search.php" method="post">
<input type="text" name="val" value="search string" />
<!-- more form stuff -->
</form>
And you can now get it like:
<?php echo $_POST['val']?>
If however, you want that value in url you should modify the form's method to get like:
<form action="search.php" method="get">
<input type="text" name="val" value="search string" />
<!-- more form stuff -->
</form>
and then you can get its value on search page like:
<?php echo $_GET['val']?>
Alternatively, you can specify search string directly in the action attribute of the form and in this case you don't need the val field:
<form action="search.php?val=<?php echo $search_string;?>" method="get">
<!-- more form stuff -->
</form>
and then you can get its value on search page like:
<?php echo $_GET['val']?>