Open/Load/View HTML file in TEXTAREA and update using PHP

What we are doing here is ‘edit an HTML on the user side’.

For example,

I have a file called manual.html. I have uploaded that file on CPANEL and only I have the accessing the CPANEL.

Now,

If someone wants to make changes in the manual, what would he/she do?They would need to ask me every time to make changes or will give me the new/changed file and tell me to upload it on the server.

There is an easy way out…

Let’s just give them an option of editing the HTML file on the server and click on SAVE/UPDATE button and save the file directly to the server.

Sounds cool right?

All you need to do is create 2 files:

  1. edit_manual.php
  2. editcontents.php

For editing the HTML file we will use html CKEDITOR.

1. Create a file called edit_manual.php
Put the following code inside it.[Copy the following code and paste it in your file ]

 

<script src="//cdn.ckeditor.com/4.5.9/standard/ckeditor.js"></script>
<center>
<form action="editcontents.php" method="POST">
<table align="center" >
<tr>
<td><textarea name="text_id" id="t_id"  rows=7 cols=17 value="<?php echo "MANUAL.html" ?>">
<?php
include "MANUAL.html";
?>
</textarea></td>
</tr>
<script>
// Replace the <textarea id="t_id"> with a CKEditor
// instance, using default configuration.

CKEDITOR.replace( 't_id' );
CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR;
CKEDITOR.config.autoParagraph = false;
CKEDITOR.config.fillEmptyBlocks = false;
CKEDITOR.config.allowedContent = true;
CKEDITOR.config.forcePasteAsPlainText = true;
</script>
<tr>
<td><input type="submit" value="Update" name="edit" /></td>
</tr>

</table>
</form>
</center>

===========================================================
2. Create file editcontents.php
Put the following code inside it.[Copy the following code and paste it in your file ]
<?php 
session_start();
$handle = fopen("MANUAL.html", "w") or die("Unable to open file!");
$text  = $_POST['text_id'];
if(fwrite($handle, $text) == FALSE){
  echo '<span class="redtxt">There was an error</span>';
}else{
   echo '<span class="redtxt">File edited successfully</span>';
}
fclose($handle);
echo '<a href="path/to/MANUAL.html" target="new">CLICK HERE TO VIEW THE FILE</a>';
?>
<br><br>
<button onclick="goBack()">Go Back</button>
 
<script>
function goBack() {
    window.history.back();
}
</script>
Below given is the image of how the output should look like:[html file opened in text area]
 

86 thoughts on “Open/Load/View HTML file in TEXTAREA and update using PHP

  1. Pingback: url
  2. Pingback: vape eliquid
  3. Pingback: site Blog Name
  4. Pingback: WOW Site Blog Name
  5. Pingback: xxlhq.top article
  6. Pingback: xxlhq.xyz article
  7. Pingback: xxlph.xyz article
  8. Pingback: xxxpics xyz
  9. Pingback: xxlph xyz
  10. Pingback: pornph xyz
  11. Pingback: xxxph top
  12. Pingback: xxlph.top article
  13. Pingback: xyz
  14. Pingback: adulthq top
  15. Pingback: xxxhd.top article
  16. Pingback: xnxxhd top
  17. Pingback: xxxhq top
  18. Pingback: pornph.xyz article
  19. Pingback: xxlhd xyz
  20. Pingback: adultpics top
  21. Pingback: xxxhq.top article
  22. Pingback: xxxph xyz
  23. Pingback: xnxxhd.top article
  24. Pingback: xxlhd.xyz article
  25. Pingback: pornph.top article
  26. Pingback: xxlhq xyz
  27. Pingback: xxlph top
  28. Pingback: xxxph.top article
  29. Pingback: adultph top
  30. Pingback: xxlhq top
  31. Pingback: adulthd top
  32. Pingback: adulthd xyz
  33. Pingback: pornph top
  34. Pingback: adulthq xyz
  35. Pingback: xxxph.xyz article
  36. Pingback: czyszczenie strony
  37. Pingback: IDLE
  38. Pingback: biquinis online
  39. Pingback: CCTV
  40. Pingback: Wooden Knife
  41. Pingback: Beitragsabrechnung
  42. Pingback: kona coffee store
  43. Pingback: kona coffee brands
  44. Pingback: pure kona coffee
  45. Pingback: kona coffee
  46. Pingback: kona coffee beans
  47. Pingback: 100% kona coffee
  48. Pingback: 100% kona coffee
  49. Pingback: Joomla extensions
  50. Pingback: screen repair
  51. Pingback: free pink noise
  52. Pingback: travel bag
  53. Pingback: machine learning
  54. Pingback: marketing digital
  55. Pingback: agente aduanal
  56. Pingback: dog boarding
  57. Pingback: good omens
  58. Pingback: eyeglasses

Leave a Reply