Question: I want to refresh the same page and display the entered value in text box on the same page after clicking the link or button.

I have the following code:

```
 <?php 
 echo '<h3>Fee Payment</h3>';

 echo "<form id='myFormId' name='myFormName'>";
 echo " <input type='text' name='myTextField'>";
 echo "<a href='{$_SERVER['PHP_SELF']}?student_no=myTextField'> Search Student</a>";

 if (!(isset($_GET[student_no])))
 { 
    echo "No Student is available.";
 } 
 else
 {
    $student_no = $_GET['student_no'];
    echo "Student NO:".$studen_no;
 }
 ?>

```

Please guide me how to achieve the goal and whats the error my code.

Answer: 
What you want is AJAX. I am just providing you an example of how you can proceed by using [jQuery](http://jquery.com/), but you can use any other library / framework or any other way also. You can check [this article](http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/) also for more usability details.

In the main page:-

```
<?php
echo '<h3>Fee Payment</h3>';

echo "<form id='myFormId' name='myFormName'>";
echo "<input type='text' name='myTextField' id='myTextField' />";
echo '<a href="javascript:void()" id="inline_submit_a">Search Student</a>';
echo "</form>";
?>

<script type="text/javascript">
$('#inline_submit_a').click(function(evt){
    $.ajax({
       type: "GET",
       url: "handler.php",
       data: {text:$('#myTextField').val()}
    });

    evt.preventDefault();
    return false;
});
</script>

```

In the "`handler.php`" page:-

```
<?php
if (!(isset($_GET[student_no])))
{ 
   echo "No Student is available.";
} 
else
{
   $student_no = $_GET['student_no'];
   echo "Student NO:".$student_no;
}
?>

```

You can write all the logic related to the database in the "`handler.php`" page.

Hope it helps.
1. You're using a link to submit the form, but you should be using a submit button.
`<input type="submit" value="Search student" />`
2. You didn't close the `<form>` tag.
3. You're using `$_GET[student_no]` which will make PHP look for a definition of `student_no`. Since it's a string, express it as one. `$_GET['student_no']` is better.