Processing JS and HTML + PHP

I’ve made a processing sketch that I had upload on my website (localhost). But the buttons that I programmed doesn’t work because i’m using the “selectInput” function that is not avaible in web. So, I guess I need to make that button in HTML, but i don’t know how to connect it with the processing sketch (I insert the sketch with echo script type etc.)

I have a second question, how do I connect that processing sketch with a data base? I need to save the last picture that a guy upload so the next guy that enters to the web can see it.

Thanks for reading!