Jump to content

Write to .txt


peter_sanders2

Recommended Posts

<p>I have gotten a web hosting account to get around the problem of PHP and ASP compilation and localization of site. It now works. It is password protected and I have a "journal" of sorts with a PHP script to write to Journal.txt. The problem is that<br>

every journal entry overwrites the previous.<br>

I want to keep every entry by writing the next entry to the next available space. This is the current script.</p>

<p><br /> Sending...<br /> <br /> $d = date("Y/m/d") ;<br /> $je = $_GET["je"] ;<br /> <br /> <br /> $myFile = "Journal.txt";<br /> $fh = fopen($myFile, 'w') or die("can't open file");<br /> $stringData = "$d \n" ;<br /> fwrite($fh, $stringData);<br /> $stringData = $je ;<br /> fwrite($fh, $stringData);<br /> fclose($fh);<br /> <br /> header( 'Location: http://fgf80homepage.hostoi.com/[insert undisclosed user page here]' ) ;<br /> ?> <br /> <br /></p>

<p>I have it in the section so that if there is a PHP compilation failure, I will know the next time I go to my website.</p>

Link to comment
Share on other sites

<p>Also, how does one go about setting up a "favicon," or what ever it is called?<br>

And, for that matter, how would I write (and process) a form similar to the form on this page for posting a reply? Could I (legally and practically) tweak the source code so that it would write to the journal.txt file? I would prefer this, using the code starting:<br>

"<p><br>

<textarea id="message wrap="physical" cols=" et cetera</p>

Link to comment
Share on other sites

<p>So you want to APPEND the new journal entry to the end of the existing file content, and not OVERWRITE the existing data. Thats it in a nutshell.<br>

I would start by checking the manual page that explains the syntax of the fopen call. This is where you are doing the file open step, opening up that journal file for a write. It may be that you need to use a different code letter instead of the 'w', perhaps a different letter that will open the file for 'appending'. Similarly, I would check the manual page for complete explanation of the fwrite function, check to see if it mentions any special opcode that will do a append type save instead of comple over-writing.</p>

<p>This script code looks similar to Perl........</p>

 

Link to comment
Share on other sites

<p>7:18 pm response:<br>

If I can legally use that code, where can I find it?<br>

It cannot be found completely on this page, and I cannot find the HTML sub-script. If I can legally use it or a variation, pleas help.<br>

Thank you, and sorry for all the after-thoughts.</p>

Link to comment
Share on other sites

Probably fopen($myFile, 'a') for append instead of 'w' for write. Looks like PHP language, not Perl.

 

If you put 16x16 favicon.ico in your home directory, most browsers treat it as your website icon.

 

Not sure I understand your 3rd and 4th questions.

Link to comment
Share on other sites

<p>@B. Tuthill<br>

3rd and 4th questions<br>

I am referring to the box located at the bottom of this page that is used to input comments and responses to a php or asp based information processing pages. I want to know the script for it. I looked in firebug, from which you cannot copy and the process would take weeks by hand, it does not appear in whole (i.e., the html sub-file that makes up the text area) when you right click and hit "view page source," and I would far prefer this box to the box that results form the html tags <input type="text" name="resulting-variable-name">.<br>

Thank you.</p>

Link to comment
Share on other sites

<p>Thanks. I am now, for all intents and purposes, done with the journal.<br>

Now I want to make it so that I click a link at the bottom of the page that will take me to a php page that will download the journal, wipe the online file clean, and redirect me back to my user page. I can do the last two, but how do you initiate an external (relative to individual page) download with the onload event?<br>

Thank you in advance</p>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...