Another CGI question. Keeping an array over more than one Webpage.

Terry Vogelaar (de Mare) tvogelaar at de-mare.nl
Sat May 8 07:16:10 EDT 2004


Malte Brill heeft op zaterdag, 8 mei 2004 om 11:07 (Europe/Amsterdam) 
het volgende geschreven:

> I´m trying to set up 4 Webpages.
>
> fruit.html
> meat.html
> perishable_food.html
> vegetables.html
>
> Each Html file has a set of forms. A desrciption of an item, a field 
> to type
> a numerical value in. The CGI should be able to add the values 
> submitted by
> the user as long as his session takes and allow to add other items. If 
> the
> user hits a "Now what´s for dinner" button the CGI should return 
> something
> like this:
>
> You got 3 bananas, 1 peach, 1 broccoli, 5 potatoes, 1 egg, 1 cup of 
> cream
> and a steak. You can do a steak with broccoli and au gratin potatoes. 
> You
> can also have a fruit salad for dessert if you are willing to spend 
> about
> 1.5 hours in the kitchen.
>
> or if there is no food:
>
> You got no food at all. Go shopping you lazy bag.

[...]

> So I would need to post the whole data I need on all 4 Webpages in 
> hidden
> Tags? Would I need to call 2 CGIs to avoid refresh errors? The first 
> to set
> all values to zero and the second to add values from there? All HTML is
> returned by the CGI created on the fly, no static HTML files? Please 
> excuse
> my dumb questions. I guess I´m thinking too static (webpages are build 
> in a
> texteditor...) here.

I don't quite understand what your objective is. A virtual grocery 
store? Or a recipe suggestion utility?
Of course you could let the CGI generate only the resulting page, but 
also the form itself. If the collection of ingredients varies, than you 
could make a stack in which each card contains a type of food. It can 
have several fields among which are the name and the category of the 
ingredient. Then you can let a script simply see which cards have the 
'fruit' category and you'll let the script use the field data on these 
cards in a table.
Modifying the stack can be done with a download-edit-upload cycle or 
you can make a content management system; ie modifying the stack online 
using a form.
The users can form a separate stack in which you could put data like 
username, password, permission to modify the stack or not, basket / 
fridge content, etc.
Also, it might be more efficient to use a single form instead of 
multiple.
I'll show you how:
  <FORM method="post" action="http://www.bananas.com/cgi-bin/add.cgi">
<INPUT type="hidden" name="username" value="Terry Vogelaar">
< INPUT type="hidden" name="Password" value="best customer">
< INPUT type="text" name="quantity" value="1">
<INPUT type="submit" name="adding" value="Apple">
<INPUT type="submit" name="adding" value="Mango">
<INPUT type="submit" name="adding" value="Peach">
</FORM>
This way, the submit button has a name and a value which you can 
evaluate by a CGI script. That way, you can see if the user wants to 
add a (number of) apples, mangos or peaches.

Terry


More information about the use-livecode mailing list