Page 1 of 1

How to write to another file?

Posted: Sun Jan 04, 2009 6:09 pm
by JKM
Hi there!

I was wondering how I could add new entries to a select list?

Code: Select all

<select name="xx">
                    <option value="banana">banana</option>
                    <option value="apples">cake</option>
                    <option value="cake">cake</option>
                </select>
The form to add new a new entry:

Code: Select all

<form enctype="multipart/form-data" action="add_entry.php" method="post">
    <input type="text" name="what" /> <input type="submit" value="Add!" />
</form>
So if I write "cookies" and press "Add!", I want the script to add

Code: Select all

                    <option value="cookie">cookie</option>
before "</select>".

Thanks for any help. :)

Re: How to write to another file?

Posted: Sun Jan 04, 2009 6:56 pm
by requinix
You're getting banana, apples, and cake from somewhere. When someone wants a new item, add it to wherever those things go.

Re: How to write to another file?

Posted: Sun Jan 04, 2009 8:10 pm
by omniuni
Could you provide a bit more information?

Are these options just for the user and just at that moment? If so, you can probably just store the list in $_SESSION[]. If you want it stored permanently, you should instead use a database, or at least a text file so that the changes are persistent.

What is your end goal, and maybe I can guide you in the right direction.