How do javascript and php interact regarding a form submission?

I have a form that has name/email, groups of radio buttons, a date selector, message area and file upload. I want the form results to be emailed to the company needing the information and another confirming the information to the user.

I do not yet know either javascript or php. My impression is that they would work together to achieve this. I would like to get a conceptual grip on the role each would play (not the mechanics of writing the scripting). I hope that will help me understand what my purpose for each is.

For example, does js gather up all the results by going through the form (name, email, radio selections, etc., and pass that information to php scripting to do something from the server side? Can I use either js or php and not both? Do I have to use a database for something?

These must be really dumb, low-level questions , so basic that no one else has to ask because I have been not been able to find the answers. Any explanations or guidance would be appreciated.

The form will need back-end processing (php). The use of js is optional, it’s quite possible to make a working form without it. It’s often used for on-page validation, but is somewhat redundant with modern browsers which have that built in. Though it still has its uses in forms.
Any client-side validation you do have must be backed up by server-side validation to be secure, but having the (optional) client-side is more user friendly.

2 Likes

Thank you SamA74. You made me think harder and investigate further. I misunderstood the role of js in a form. I thought that somehow js collected completed information in a “valid” form and somehow passed it into php for further action server-side. Based on the Comments on this js article I will work on HTML 5 compliant forms, not be concerned right now about js validation because it may not be required for my form anyway, and apply my time to learning php.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.