Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Editing external .txt with php
Old 07-17-2006, 04:36 AM Editing external .txt with php
Ink
Novice Talker

Posts: 13
Trades: 0
Hi, im not too good at php, and i need some help
I got a memmo file on my server, where i write everything i need to remember(serials, tlf nr, etc) I dont have the opertunety to use ftp on my school and my work, so im trying to make a php script that alowes me to read and edit the file with php.

My problem is that i cant get the saving function to work proppely.
I want the whole script in one file. and i want the save action to not direcy me away from the txt file. (so that i can save, get a msg that says that it went ok, and then leave the page open until i need it nxt time..

accualy i think it dont save at all anny more:P i destroyed it when i tryed to fix it

memmo.php
<?php

$username = "ink";
$password = "pass";
if ($_POST['userlog'] != $username || $_POST['passlog'] != $password) {
?>

Login for Memmo.txt
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<label for="userlog">Username:</label>
<input type="text" title="Enter your Username" name="userlog">
<br><label for="passlog">Password:</label>
<input type="password" title="Enter your password" name="passlog">
<br><input type="submit" name="Submit" value="Login">
</form>
<?php
}
else {
?>

<?

$filename = "memmo.txt";
$fp = fopen ($filename, "rw";

echo "<form method=post action=motor.php>\n";

echo "<textarea rows='30' cols='100' name='content'>\n";


$content = fread ($fp, filesize ($filename));
echo $content;

echo "</textarea><br><br>";

fclose ($fp);

echo "<input type=submit value=Save>\n";

echo "</form>";


?>




<?php
}
?>

motor.php
<?php

$filename = "memmo.txt";

$fp = fopen ($filename, "w";

// write to file
if (!fwrite($fp, $_POST['content'])) {
echo "Unable to modify the file";
exit;
}

echo "<div align="center" valign="center"><p>Memmo.txt was updated succesfully.</p><p><a href="munchmoller.com/memmo/index.php>Back</a></p>< ;/div>" ;


fclose($fp);

?>
Ink is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-18-2006, 10:04 PM Re: Editing external .txt with php
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Lose the semicolin after the handler in the fopen function:

$fp = fopen($filename, "w");
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Editing external .txt with php
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23152 seconds with 12 queries