Ask HN: Best way to turn a simple static website interactive with PHP?
I'm able to easily design a static website with Bootstrap, but struggle as a non-dev with connecting simple things like forms, although I have some basic PHP knowledge.
A friend helped me with setting up Netlify and React, but I find it to be over engineered for my simple requirements and always need to ping him when I have to make some small changes. What I'm looking for is support for templates to minimize recurring code and submitting forms.
What can you recommend and is easy to set up?
28 comments
[ 2.0 ms ] story [ 27.3 ms ] thread[0] Examples: https://wordpress.com/pricing https://webflow.com/hosting
My question is; if you can build it, why not take the and get a shared hosting account and write the php yourself? Is OP able to list the obstacles?
When someone POST a form, you can use the $_POST superglobal to extract all of that information from the submitted form.
Then, you can store that information in the $_SESSION superglobal.
Lastly, when the user visits a page with the same or similar form entries, you can actually “echo” their own answers from a previous page into the form.
This is baby’s first PHP here, not really production grade, but still quite useful.
At this point, you don't need a best practice recommendation, you need the learning experience and working with PHP by itself will give you that without a lot of headache.
go from there
See https://laravel.com/docs/5.8/blade for specific documentation on templates and forms, although I would recommend a more comprehensive look through the documentation, or working through a tutorial.
https://lumen.laravel.com/docs/5.4/
You just have to be really careful particularly with any data input fields you have when you roll your own code, as that's pretty much the primary assault vector for exploiting PHP websites.
(I'm assuming you just want to collect submissions in a table, or send them somewhere via Zapier, and don't need to do anything interactive with the info you collect.)
You could use google forms for free and push the results to a google sheet.
https://formtoemail.com *No affiliation
I will go ahead and create a static website, add some simple PHP to include header and footer on each page (either w/out any framework or Lumen) and apply some Zapier (or Netlify) magic to make forms work.
Once the MVP is validated, we might as well switch to some other framework or stack but for now, this is totally doing the trick.