Fix javascript

you need to validate what the javascript sends to the php, or else you will get hacked 
you are treating these like they are dynamic when they are not. That's probably because you are use to working within angular, which has 2 way data-binding, so variables are dynamic. What I mean by this is that once a variable is set in javascript, it will not change. 

For example, var clientName = document.theform.name.value . Since this code will run right when the site loads before the user has a chance to fill in anything, clientName will equal '', or nothing. If the user enter 'foo' into the name input, that will not affect the value of clientName.