JavaScript Form Preprocessing for PHP
Now that the concept of JavaScript’s role with PHP is clear, it is time to do something more practical with JavaScript and PHP. This next set of scripts uses JavaScript as a preprocessor to make sure that a comment form being sent has all of the forms filled out and that the user remembers to include an “@” sign in her email address. The JavaScript also shows how to combine two functions into a single function that performs two tasks.
Before starting, you need to know a PHP function not yet discussed. The function mail(e,s,m,h) has four arguments:
e Email address
s Subject
m Message
h Header
Each of the arguments can be set as variables or strings in quotation marks. For example, this line would fire off ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access