FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

need php help save command

 


golles
Hi, I'm making an admin panel for a site, The site just reads the boddy out of a txt file. I have for every page an admin page. but I need to make for all pages a save page. is there an option so I only need one page to save the txt file?

(maybe usefull: the name of the txt file is the same as the name as the textarea but without the .txt)

Hope someone can help me!

thanks in advance


//golles
golles
now I have 4 files.
index.php
index.txt
admin_index.php
save_index.php

index.php shows the text in index.txt
admin_index.php loads index.txt in a textarea
save_index.php saves the textarea to index.txt

Only it aint working. it only clears index.txt Sad

this is the code on admin_index.php
Code:

<form action="save_index.php"><textarea name="indexbody" rows="11" cols="104"><?php $fn = "index.txt"; print htmlspecialchars(implode("",file($fn))); ?></textarea>
<input type="submit" value="Save"> <input type="reset" value="Reset">


and this is the code in save_index.php
Code:

<?php
$fn = "index.txt";
$content = stripslashes($_POST['indexbody']);
$fp = fopen($fn,"w+") or die ("Error with opening file!");
fputs($fp,$content);
fclose($fp) or die ("Error with closing file!");
?>


I hope someone can tell me what I'm doing wrong?
thanks in advance!!!


//golles
golles
fixed myself (A)
sonam
Hi,
T am not pretty sure, but I thing that your problem is in form code. This form have <form action="save_index.php"> but how I know form need method of submission, GET or POST. Try this:
<form method="post" action="save_index.php">

Sonam
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.