How can i edit a text file on a server and how to receive it back in a text box.And at last how to check wether a particular word is there or not.

If you can get any of this then please let me know at kvermamanas@gmail.com

You may tell me in javascript side server language or anything else.
I will be grateful as i am only 13.

Recommended Answers

All 2 Replies

I believe it is php your wanting to use if the file is stored on the server.
There is a nice function called file_get_contents() and file_put_contents(). Below is an example of how to use them.

<?php
$file='path/to/file.txt';
$data=file_get_contents($file);
echo '<textarea name="text">';
echo $data;
echo '</textarea>';
if (isset($_POST) && !empty($_POST)) {
file_put_contents($file,$_POST['text']);
}

For checking word is there or not:
Here is code:

<?
	$file='path/to/file.txt';
	$data=file_get_contents($file);
	$findme  = 'some word';
	
	$pos = strpos($data, $findme);
	
	// Note the use of ===.  Simply == would not work as expected
	// because the position of 'a' was the 0th (first) character.
	if ($pos === false) 
	{
	   echo "The string '$findme' was not found";
	} 
	else
	{
	   echo "The string '$findme' was found and exists at position $pos";
	}
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.