Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
JS/CGI and Files
#1
How can I write to files on the server using JavaScript or CGI, the way the QB INPUT and OUTPUT statements do? As in, if I wanted to use a text document to store names and messages in a guestbook?
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
Reply
#2
javascript: not possible. on tricky netscape configs you can write files, but yeah, not possible.

cgi:

open (HANDLENAME, "filename");
print HANDLENAME "stuff to write";
$nextline = <INPUT>;
seek works like its qb counterpart
read works like get
tell works like seek used as a function in qb.

now, when you open it, the filename indicated the mode. there are a bunch of read write combinations (http://www.perldoc.com/perl5.8.0/pod/perlopentut.html ), but you only really need 3:

open (HANDLENAME, "filename"); #read
open (HANDLENAME, ">filename"); #write
open (HANDLENAME, ">>filename"); #append

look up the functions in the perl documentation. as perl.qb45.com is down, i'll send you to http://www.perldoc.com/

edit: i fixed a brainfart on my part.
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#3
THANK YOU!!!! Big Grin
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
Reply
#4
javascript is very much possible. As far as I know you have to write it as an array, though.

Then you can link to the file:

<script src="myfile.js"></script>
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#5
How would i do that?
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
Reply
#6
With javascript it is not posible to write to a file on the server. Javascript runs client-side, and not server-side [AFAIK].
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#7
Ack. I can't find Perl on "comcast.net", so I can't use CGI. Is File I/O possible with PHP?
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
Reply
#8
Quote:Ack. I can't find Perl on "comcast.net", so I can't use CGI. Is File I/O possible with PHP?

Yes, php does file I/O. Very similar to perl.
Reply
#9
hey, can you point me to a script as an example?

thanks
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
Reply
#10
http://www.php.net/manual/en/function.fopen.php
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)