Since you've gotten the correct $_POST variables according to your comment, you need to fix this now
$nesne=str_replace($keywords,'<a href="$link" title="$keywords" target="new">$keywords</a>',$text2 ,1);
You cannot put variables in a single-quote delimited string - use double quotes around it with single-quotes inside.
Like this:
$nesne=str_replace($keywords,"<a href='$link' title='$keywords' target='new'>$keywords</a>",$text2 ,1);