I'm trying to use some type of a mail merge where PHP reads the text file but in that text I'm trying to "replace" some keywords so that if I add "#FIRSNAME#", "#LASTNAME#, "#EMAIL#", replaces that with the entered fields on the form on the mail() function.... The form I have has 10 of the same field names meaning: 10 first name fields, 10 last names, 10 emails. I used the "for" loop to spit out 10 same HTML inputs (I did this rather than typing 10 HTML input tags of the same kind). PHP processes this form with validation. Using the mail() function.
My code that works currently where form and PHP processes it on the same page "myform.php":
<?php validation ?> // looks at if there are empty fields and or if submitted
<form>
for($i=1; $i <= 10; $i++) { echo '<input firstname etc> <input lastname> <input email>';}
</form>
<?php
//print or echos the "Thank you" if there's no problem with the form
//emails... I currently have HERE'S MY code that I want to use file_get_contents function somehow
$body = "Thank you {$_POST['firstname'][$i]} for registering with the blah blah blah blah!";
mail($_POST['email'][$i], 'Party Invitation', $body, 'From: email@example.com');
}
?>
The external text file that I would like to "read" and mail merge keywords...
You have requested this form... you're invited to our party..
Name: #FIRSTNAME# #LASTNAME#
Email: #EMAIl
I'd like to replace these keywords with $firstname and $lastname using the external text file so that this will be sent as an email message using the mail() function. Can that be done? The reason is that this external text file is like a "template" that I'd like to change.