Hey, My Brain is Trapped in a Computer!
I was trying to come up with an idea for a new code sample that would let me learn some ReactJS and combine it with a bit of PHP, preferably something silly and dumb and fun to make. Then I heard The Flop House podcast’s episode about The Computer Wore Tennis Shoes, and Elliott Kalan improvisea a fake web site idea during an ad read, as usual. This one, HeyMyBrainIsTrappedInAComputer.com, struck a chord with me, so I decided to create it.
Notes:
My web host does not allow me to run NodeJS/npm, so I had to include React via Javascript instead. The resulting code may be structured differently from a enterprise-level React page.
index.html uses React to output the form and maintain the state variables, then submits the form data via Axios to trapped_email.php, which creates and sends the email and returns status data. The submit button is disabled on a successful email send. Form validation is performed by more traditional JS on submit, backed up by server-side validation in PHP.
As a relative newcomer to React, there may be better ways to approach the code I’m not aware of, and I’ll update it as I encounter them.