Hi, thanks for looking at our project! This should be a pretty simple one. It’s a quick modification to an existing PHP sendmail script, NEW_contact.php, which I’ve attached.
As you would expect, this PHP sendmail script gets information from a form on our web site. For most form submissions, the script sends a straightforward HTML email containing the info on the form.
However, for certain submissions that match a certain “recipient” field, it also sends a secondary email in XML/ADF format.
The mod we need is this:
We need a change to the way the script constructs the XML/ADF secondary email.
Right now, the contents of the form’s “recipient” field contains the full name of the form submitting user, and this becomes a variable called “$name”. This is passed into the XML like this:
<name>’.$name.’</name>
What we need is for the script to be modded so that it instead takes this input and splits it into three variables — $name, $first_name, and $last_name.
The recipient field can be passed directly to $name. However, this should then be parsed so that the first word/string goes to $first_name and any subsequent text goes to $last_name.
So, if for example, the form posts a recipient value of “John Smith”, the XML should thus be written as:
<name part=”full” type=”individual”>John Smith</name>
<name part=”first” type=”individual”>John</name>
<name part=”last” type=”individual”>Smith</name>
If there is only one word in the recipient, i.e., “John”, it should look like this:
<name part=”full” type=”individual”>John</name>
<name part=”first” type=”individual”>John</name>
<name part=”last” type=”individual”></name>
Another example: “John P. Smith”
<name part=”full” type=”individual”>John P. Smith</name>
<name part=”first” type=”individual”>John</name>
<name part=”last” type=”individual”>P. Smith</name>
Does that make sense?
Please let us know if you have any questions. Thanks!