Forum Moderators: coopster
I'm trying to separate the data I recieve from a form into diferant pages.
This is the code I got at site at the moment:
<form method="post" action="response.php">
Char name: <input id="username" name="username"> <br>
<input value="math" type="checkbox" name="major[]"> Mathmatics <br>
<input value="english" type="checkbox" name="major[]"> English <br>
<imput value="history" type="checkbox" name="major[]"> History
<input value="Submit Query" type="submit">
What I need is in the response.php a code that would divide the information and wright it to diferant html's files.
For example, if a person checked math and history, it would be written in "math.html" and "history.html" there username, thous creating a list on these differant pages. Also if a same person would go and change there options, the code would go and erase if needed, and if a same response would have been chosen, not rewrite the name, as to create an updated list with no repetition of names.
Thank you for your help
writing and editing html files based on form input seems like a lot of work. Work that a database is perfectly designed for.
I would suggest using a database and then each page can select the usernames with a column value set that applies to them or some such mechanism.
If you specifically need to do it in files, like if it's a school project or some such, then you would be better off writing the list in a textfile and including the appropriate text file on the appropriate page, thus not having to parse through a ton of html every time.
you could have a row for each user/individual that had each setting (math/english/history) set to yes or no, then use your query to find the ones who listed math and show those, or the ones who listed math and history and show those.
Then if someone changes their entry you could just update the row by putting yes and no where required.
This would work best if the list iof majors is small and fixed. If you ahve a very long list then you would need something more dynamic. Maybe a user table, then a majors table. Then a third table that matched the two together, I have always called it a links table and they are used for many to many relationships.
I tried to keep my explanation simple but there is quite a bit of reading behind it.