How to write to another file?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

How to write to another file?

Post 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. :)
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How to write to another file?

Post by requinix »

You're getting banana, apples, and cake from somewhere. When someone wants a new item, add it to wherever those things go.
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: How to write to another file?

Post 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.
Post Reply