Firstly, it is not "unsafe" to store such data in the database. If you have returning customers and want to offer them a service so as not to re-enter the information ALL TIME, using a database is an idea. To make this idea safe, you will need policies for administering the database, access to the server, and proper data protection (e.g. hashing, encryption, etc.)
As for your script, if you send data via POST to a PHP script, the PHP script will certainly have to talk to the database (whether it is your local one or a connection made for a credit card script).
In order to answer your question, you need to know EXACTLY what the script requires before judging what you need to do locally. If the script just accepts the input and returns a value, then you will need to integrate it into your WebApp.
More if any?
dulac source share