The sample.txt is located on the web server, I was able to make this work but my problem now is how do I use the same php file on opening other text file without specifying filename on the php file itself?
You can get URL value's with $_GET[] array, in your sample URL ( http://somesite.com/readarticle.php?name=sample.txt ) it would be $_GET['name']; . Be warned to use this cause this brings potential security leeks with it. you should read up on the problems with it.