Sorry bud. Php is not my strong suit. I can’t just look at it and see the error. I’d have put it all together and test and stare at my desktop for many many minutes prob to fix. Someone else will swoop in and spot the error.
You can js will prevent the form from being submitted until all required fields have been filled out correctly. Once it passes the js then it submits and php reads it. The way I do it is to simply have my js validation mirror my php validation. If you have js in place only 2% will ever need to be validated by the php.
Okay, I will try this @eric, thank you. To be clear, will I still be using the PHP to send the form to the email address? This new line of JS will work hand in hand with the PHP, correct? My above PHP code does work, but it just won’t make the fields REQUIRED. Will the above JS make the fields REQUIRED? Thank you sir!
Everything you said is spot on. Nothing will change with the way it currently works. But you will eventually want to get some php validation in there. Spambots could use your form for all kinds of spammy things.
But oh it works you just need that one thing? Someone will write hat for you in two secs
Server-side validation is **always necessary**.
> This new line of JS will work hand in hand with the PHP, correct?
**Edit**: I may have misunderstood your question, here. No, they don’t work together (i.e., they don’t *interact*), but you may have been asking if they would *conflict* with each other? If so, that’s unlikely. **/edit**
If you’re still trying to figure this out, please point me to your code, and I’d be happy to help.