Judging from the title, you’re probably thinking that maintaining that many clients isn’t the easiest job in the world. You’d be right in thinking that, the question is how do you keep on top of that many websites in a small group of 4 web developers? Throughout this article, this is my solution while working for Physio123 to compose a solution for a large scale client base.
What’s the problem?
The problem currently is that 200 forms need maintaining across a large scale of customer sites. Adding spam protection to contact forms across already existing sites can take a long time to produce a solution for. So what’s the solution? My proposed solution is to build a database management system, which can connect with all 200+ sites.
To kickstart the process, first the developer must fill out the form on the left, this form allows the option to modify the label, the placeholder the input (text, textarea, password, email, radio, checkbox, dropdown), the class, is the field itself required (such as an email address) and a name attribute.
The following json code will be generated per field, this will contain all the attributes mentioned above, however the option value will remain empty. Due to this being a text field only, the option field will store an array value for radio buttons, check boxes and dropdown menu’s. This is to allow multiple labels to be generated throughout within the final form.
How to control 200+ forms sending.
Generating a large scale of forms is the easy part of the task, the difficult part is discovering how these forms will actually send. Or is it actually difficult at all? Once a form is submitted to a database, there is control over where the form will send to which is convenient for forms which need to send to different emails on the same site.
However, the magic behind sending a form can be found below. What happens here is the email template actually generates itself, dependant on what is being sent to the PHP processor file.
Within this example, row-template.html is a segment of the table this will generate a row for each field that is sent to the file. For example one form may contain (Name, email, comment), while another form may contain (Name, Email, Phone Number, Location, Comment). Normally, these are sent to two different processor files to statically work for these values, however using this looping method cuts down the amount of work used.
What is meant by this is that the $_POST method in which PHP uses to store form values can actually be looped through, which is being done within the following code. Doing this can dynamically generate a unique html email for each form to be sent to its corresponding address.
All this data will be gathered from the database, dependant on the site it is on.
*Note this is still a concept, production has not yet been started.