The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
All I want is a basic script that allows information that is submitted through a text box to appear on the site.
When I say basic I mean basic as in monkey_man's old chat scripts he used to have on his site.
Anybody know of any basic tutorials that could explain how to do this?
I've got a feint idea of what to do, just not how to do it!
Thanks.
s.
All I had to do was to write the thingy and it worked fine...
It's funny. It really is.
*laughs to self*
Say I was to insert this:
Test
Test
Test
Test
Into a text box and write it to a text file using this code:
if ($Data) {
$Data = stripslashes($Data);
$File = "file.txt";
if (file_exists($File)) {
$fp = fopen($File, "w");
flock($fp, 2); # Lock the File.
fputs($fp, "$Data\n");
flock($fp, 3); # Release the File Lock.
fclose($fp);
[CUT]
I can then call it up on a page using this code:
$File = "mainframe.txt";
if (file_exists($File)) {
$fp = fopen($File, "r");
flock($fp, 1); # Lock the File.
while (! feof($fp)) {
$Line = fgets($fp, 1024);
print "$Line
\n";
}
flock($fp, 3); # Release the File Lock.
fclose($fp);
} else {
print "
Can't include the text, file doesn't exist or
can't be opened.
}
?>
And it displays it how I submitted it in the text box.
Say I wanted to call the contents of the text up within a text box so I could edit it, if I used that code above it would display the text like this.
Test
Test
Test
Test
How would I edit that code I used to call up the text so that it deletes all the
bits? If they're there they end up making bigger and bigger gaps each time the data is submitted.
from the data while it is in your textarea box, but put back when you submit it, so the
's are still in place in the file???
Why not have something like this:
$newstring = str_replace("
", "\n", $string);
... before writing the data to the textarea, then this after it:
$newstring = str_replace("\n", "
", $string);
There isn't a $string in there.
I just saw the thing posted today and thought that it may have some relevance to the subject!
I've got to include the $string in there somewhere haven't I?
I just don't have a clue...
-------------------
See, I don't actually know what I'm nattering on about. I just saw it and thought, 'hmmmmmmm.'
$newstring=str_replace("
", "",$string);
Where does the data for $string come from? Seems empty to me
Why not have a seperate variable with the same data, but which has the
removed, so you display it with the
but write it back without?
Like I said, off to eat, so will read it correctly later :)
I'm probably doing this the wrong way in the first place but I don't care!
I'm using the code:
$File = "mainframe.txt";
if (file_exists($File)) {
$fp = fopen($File, "r");
flock($fp, 1); # Lock the File.
$newstring=str_replace("
", "",$string);
while (! feof($fp)) {
$Line = fgets($fp, 1024);
print "$Line
\n";
}
flock($fp, 3); # Release the File Lock.
fclose($fp);
} else {
print "
Can't include the text, file doesn't exist or can't be opened.
\n";}
?>
To open up a text file from within a form box so that I can edit something and then submit it again as it's edited form.
Thing is, because of all the
bits in there, unless I delete them by hand they just keep leaving bigger and bigger gaps between sentances.
How would I go by getting rid of the
bits so that they will not appear when I open the file? When the text is resubmitted the new
bits will automatically be created by the code.
(This is where I'm gonna make stuff up which won't make any sense!)
I'm gonna guess that it's got something to do with this from MMs thread.
$newstring=str_replace(" ", "",$string);
Which can be edited to something like this:
$newstring=str_replace("
", "",$string);
How would I go by inserting that into the original code so it kills the
bits?
ELSE
Tell me the correct way to do it and not the way that I've just made up.
:c)
Thanks.
Just seen what it would look like with loads of blank lines because of wrapped data and it looks poo.
So much better when each line is a new date and the information goes sideways. it may be a bit of hassle but it's the best way (and easiest for me!)
Hmmmm, just thought about maybe changing the font size....