Edit File php
After you have hosted your file in a web server you could not access your file for editing further more.But as an admin you could keep page like bellow for php editing under admin authorization.
Above file contain the code of itself which could be edited and save. bellow I have shown the necessary codes.<form action="write.php" method="post"> <table bgcolor=#efc9be align="center"> <tr><td><textarea name ="data" rows="20" cols="40"> <?php $lines = file('read.php'); foreach ($lines as $line) { echo htmlspecialchars($line); } $fileString = file_get_contents('read.php'); ?> </textarea></td></tr> <tr><td align="right"><input type="submit" value="Save"/></td></tr></table> </form>vv |
write.php
<?php $data=$_POST['data']; $myFile = "read.php"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData =$data; fwrite($fh, $stringData); fclose($fh); header("location: read.php"); ?> |
Good information about Best PHP Hosting Service.Thanks for sharing.
ReplyDelete