matak
06-28-2007, 10:48 AM
Hey guys. I need some help here :)
I'm trying to build a text editor. But i don't know how to define function from hyperlink. I know how to use $_GET and that, but this is what i need.
Folders are like this
--includes
--files
-index.php
My index.php contains function that reads Files dir, and includes some functions to use in editor, that's write.php. Editor is also in includes folder, that is editor.php.
Now in index.php i generated my links with simple readdir found on php.net like this
if ($handle = opendir('files')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
#this is the problem part
echo "<a href=\"?edit=$file\">$file</a><br />";
}
}
closedir($handle);
}
Now i think that ?edit=$file can be used to call edit function which is defined in some other file like write.php
But i have this problem with editor.php, where i want to use my textarea to edit that file. It looks like this
<form method="POST">
<p><input id="title" name="title"></p>
<p><textarea name="tekst" wrap="virtual">
<?php #what to write here so that it uses that ?edit=$file link ?>
</textarea></p>
<p><input type="submit"></p>
</form>
I guess this could be solved with using sessions, but i don't think that that is necessary, and i would really like for u guys to help me figure this out.
Thanks
I'm trying to build a text editor. But i don't know how to define function from hyperlink. I know how to use $_GET and that, but this is what i need.
Folders are like this
--includes
--files
-index.php
My index.php contains function that reads Files dir, and includes some functions to use in editor, that's write.php. Editor is also in includes folder, that is editor.php.
Now in index.php i generated my links with simple readdir found on php.net like this
if ($handle = opendir('files')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
#this is the problem part
echo "<a href=\"?edit=$file\">$file</a><br />";
}
}
closedir($handle);
}
Now i think that ?edit=$file can be used to call edit function which is defined in some other file like write.php
But i have this problem with editor.php, where i want to use my textarea to edit that file. It looks like this
<form method="POST">
<p><input id="title" name="title"></p>
<p><textarea name="tekst" wrap="virtual">
<?php #what to write here so that it uses that ?edit=$file link ?>
</textarea></p>
<p><input type="submit"></p>
</form>
I guess this could be solved with using sessions, but i don't think that that is necessary, and i would really like for u guys to help me figure this out.
Thanks