ID:179010
 
I have no idea how to go about saving using BYOND CGI, I've tried many things and failed. Can someone please point me in the right direction on this matter?
Nadrew wrote:
I have no idea how to go about saving using BYOND CGI, I've tried many things and failed. Can someone please point me in the right direction on this matter?

What do you want to save?

Normally you'd write things out to a savefile.
In response to Deadron
Well here's my problem, when I create a page using BYOND CGI and then try to add to the page using a form it acts as if the previous page didn't exsist and the new page over writes it. I tried a savefile except I don't think I saved it from the proper location, I tried saving it in CGI/New() with no luck. This is one of the things I tried:

var/log 
var/timeformat = "Day Month DD, YYYY at hh:mm:ss"
Form/newsupdate
submit = "Update news"
var
title
comment
comment_interface = TEXTAREA
HtmlLayout() return \
{"
Title:
[title]
<br><br>
Comment:
[comment]
<br><br>
[submit]
"}

ProcessForm()
log += "[html_decode("<table border=2 bordercolor=black cellpadding=3 cellspacing=0><tr><td>News by [usr] on [time2text(world.realtime,timeformat)]</tr></td><tr><td>News title: <b> [title] </b></tr></td><tr><td>Comment:<br><font color=red>[comment]</font></tr></td>")]"
usr.displaynews()


mob
proc
displaynews()
usr << browse(log)
updatenews()
var/Form/newsupdate/N = new()
N.DisplayForm()
CGI/default_form = /Form/newsupdate


CGI
authenticate = 1
New()
var/savefile/F = new("[world.name].news")
F["news"] >> log
Del()
var/savefile/F = new("[world.name].news")
F["news"] << log




That saved the page, but everytime the refresh button was pressed it would add the old page to the new page.
In response to Nadrew
I'm just starting to play with the CGIlib, but it seems to me it would be better to make specialized forms for loading and saving instead of sticking them in CGI/New().

For instance:
Form/news
HtmlLayout()
LoadNewsFile()
return NewsFile2HtmlPage()

Form/submit_news
ProcessForm()
AppendFormInput2NewsFile()

The news form just displays the data in the news file and has a link to the submit_news form. The submit_news form appends the new information to the file after the user hits submit.