SIMPLE PAGE / FILE CONTENT EDITOR USING PHP

Kali ini saya akan share script PHP untuk mengedit isi konten yang dari suatu file sama halnya seperti teks editor  WYSIWYG, namun perbedaannya kalo WYSIWYG pada umumnya mengedit konten/tulisan yang ada di database klo script ditutorial ini adalah untuk mengedit konten/tulisan dari sebuah file yang ada di storage/server. Bisa juga dipadu dengan teks editor  WYSIWYG tinggal rubah saja textareanya mnggunakan plugin WYSIWYG atau Codemirror.

Ok langsung saja berikut scriptnya:
<?php // configuration $url = 'http://localhost/editfile/index.php'; $file = 'file/apaja.html'; // check if form has been submitted if (isset($_POST['text'])) {   // save the text contents   file_put_contents($file, $_POST['text']);   // redirect to form again   header(sprintf('Location: %s', $url));   printf('<a href="%s">Moved</a>.', htmlspecialchars($url));   exit(); } // read the textfile $text = file_get_contents($file); ?> <!-- HTML form --> <form action="" method="post"> <textarea name="text" style="background:#333;color:f1f1f1;width:100%;height:600px;"><?php echo htmlspecialchars($text) ?></textarea> <input type="submit" value="Simpan"/> <input type="reset" value="Ulangi"/> </form>

Share on Google Plus
0 Komentar untuk "SIMPLE PAGE / FILE CONTENT EDITOR USING PHP"

Back To Top