5

The hardest thing about writing code that works can be logic. For example, figuring out how to say you want to go to the next page when the form submit button is pressed, but not actually move to the next step is an error was thrown during processing.

This is one of those times when. I force a random member of my family to sit there and listen to me talking, pretty much to myself, until I figure it out. But hey, it generally turns out pretty good! (If not my energetic nephew)

Comments
  • 2
    You'll need to use Sessions or AJAX to pull this off. There's tons out there on multi-step forms using both methods, it's a common problem and a good one to solve on your own steam! 👍🏻
  • 0
    @pixeltherapy I got it fully working by adding a final else to use the "action" index when including (that's if there is an error message of course). This only works because my form sets step to 2 (for example), and action to 1. This indicates that the next page is 2, but the information was submitted from page 1 (so that if there are errors, page 1 cab be included instead of 2).

    Sessions and AJAX are things I'm currently learning about, but for now it seems this works OK.
  • 1
    Once you get the hang of ajax I'd definitely try to rewrite it, since that would make it look smoother than loading a new page everytime. But anyway good job on figuring it out :) That's a whole new level of rubber duck debugging
  • 0
    @octacian fair play! :) There are huge improvements you could make to this, but getting it working is the first step on that road. 👍🏻

    Look into sessions first as it will serve you well, even if you never use them again. AJAX is awesome but can take a little more effort to get to grips with.

    Good job! 😊
Add Comment