Basically what I am trying to accomplish is have users be able to type in a certain word on one cgi script (which I currently have) and then it will save that entry in a list and display that word and the whole list on the other page. Also I will save it into a .txt file but first I am trying to figure out how to display the whole list. Right now it is only showing the keyword the user enters.
Share
There’s no way your code could ever accumulate a list of keywords over multiple posts. Firstly, CGI scripts have no state, so they will start from a blank list each time. And even if that wasn’t true, you explicitly reset
keywordsto the blank list each time anyway.You will need to store the list somewhere between runs. A text file will work, but only if you can guarantee that only one user will be accessing it at any one time.
Since you’re new to CGI scripts, I’ve no idea why you are trying to learn them. There’s very little good reason to use them these days. Really, you should drop the CGI scripts, use a web framework (a micro-framework like Flask would suit you), and store the list in a database (again, an unstructure “no-sql” store might be good for you).