require '../vendor/autoload.php';
use PhpOfficePhpWordTemplateProcessor;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Capture form data
$formData = [
'trademark_no' => $_POST['trademark'] ?? '123456',
'trademark_name' => $_POST['trademarkname'] ?? 'Abc Trademark',
];
// Load the template
$templatePath = './data/Temp.docx';
$templateProcessor = new TemplateProcessor($templatePath);
// Replace placeholders in the template
$templateProcessor->setValue('Trademark_Number', $formData['trademark_no']);
echo "Trademark_Number Placeholder Value: " . $formData['trademark_no'] . "<br>";
// Save the generated document
$outputPath = './affidavits/generated_affidavit1.docx';
$templateProcessor->saveAs($outputPath);
echo "Affidavit generated successfully. <a href='$outputPath'>Download here</a>";
} else {
// Display the form if not a POST request
}
enter image description hereThis is my template word file snap.
I am expecting change trademark number in generated docx file but i am facing probelm it not changing value can you tell me what is the problem??