PHP Classes

File: edit.php

Recommend this page to a friend!
  Classes of Er. Rochak Chauhan   AJAX Edit In Place   edit.php   Download  
File: edit.php
Role: Auxiliary script
Content type: text/plain
Description: Server side file to save changes
Class: AJAX Edit In Place
Edit and save a paragraph of text in an HTML page
Author: By
Last change: Resolved Issue with multiple files.
Date: 18 years ago
Size: 595 bytes
 

Contents

Class file image Download
<?php
   
/**
     * This file saves the edited text in the database/file
     */
   
if ($_POST['id'] == 'desc' ) {
       
$fp = fopen('text.txt', 'w') or die("Failed to open file for writing.");
       
$content = $_POST['content'];

        if(
fwrite($fp, $content)) {
            echo
$content;
        }
        else {
            echo
"Failed to update the text";
        }
    }
    elseif (
$_POST['id'] == 'desc2' ) {
       
$fp = fopen('text2.txt', 'w') or die("Failed to open file for writing.");
       
$content = $_POST['content'];
        if(
fwrite($fp, $content)) {
            echo
$content;
        }
        else {
            echo
"Failed to update the text";
        }
    }
?>