Weekly Sprint 9 (4/12)
The last big task I need to complete before the showcase is the Story Builder feature, where users can select from their saved characters, plots, and settings to create a cohesive story. To do that, I needed to learn about multipage forms in PHP, because the user will go through 3 page — characters, plots, and settings, and then finally end up at a results page.
I had a lot of trouble with this at first. At one point I think I was more frustrated than I had ever been working on this project before. A lot of the resources I found online dealt with forms that didn’t use checkboxes, so that each input could be saved to its own session variable. Since I am dealing with checkboxes, I had to find a way to save all of the options to one session. I tried a bunch of stuff that didn’t work, and then I decided to go back and take a look at my old code that I used for the filtering pages. If it worked there, it should work for this form too, right?
This didn’t work, and I didn’t understand why. I was saving the character checkboxes in the session, just like I did on the other pages. I sat here for hours searching all over the internet. Everything I found told me it should work. Then I realized — on the other pages I didn’t have the brackets when saving to the variable. I took them off. It worked:
The (almost) last great hurdle of my project was conquered. Now in the final couple of weeks I want to add in a final step after choosing settings where the user can give their story a title, which will be displayed instead of “Your Story”. I also need to find a way to save the story to a text file without also saving the HTML elements. I found a way to save it as an HTML file that looks nice in a browser, but not in a text editor. I think I know how to send it in an email — the register/login system is already using the phpmailer library, so I should be able to just use that.