my actual link is
http://www.website.com/testing/xyz.php?id=2
but when i use PHP_SELF it is refreshing and the url turn as http://www.website.com/testing/xyz.php
please reply

This is because all GET variables are lost. The page reloads, so the url is set to the default. If you want to pass GET variables to POST, insert them in hidden fields into the form, then grab them again using POST. Here is a sample:

<?php
$get = $_GET['variable'];
?>
<form>
<input type="hidden" value="$get" name="get">
</form>
<?php
if(count($POST)>0)
{
     $postedGet = $_POST['get'];
}
?>

Or simply adding the id again:

<form action='<?php $_SERVER['PHP_SELF'];?>?id=<?php $_GET['id'];?>' method='POST'>

Maybe not pretty, but I hope it gives some clues to what I'm suggesting.

Or maybe put the $_GET variable into a session and fetch it after page reloads.

thanks for your replies
the below code is working for me

<form method="post" name="form2" action="<? echo $_SERVER["REQUEST_URI"]; ?>"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.