I have some content coming from database. And I want to replace the specific word of the content with a bunch of code.
Content coming from database is for example:
Thank you for interest on our web site.
{FORMINSERT}
You can
also contact us by calling us to 1234567890
I want to replace the string {FORMINSERT} with a bunch of PHP code. If it is a normal text string I can simply replace it by using str_replace.
But the replacing content is not simple text it is form code.
want to replace this {FORMINSERT}
with example:
<form method="post" id="form1" action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>">
<table cellpadding="5" cellspacing="2" >
<tr>
<td width="84" ><a name="contact" id="contact"></a></td>
<td width="384"> </td>
</tr>
<tr>
<td colspan="2" ><h1>Contact Us</h1></td>
</tr>
<tr>
<td ><label for="fullname">Name:</label></td>
<td>
<input type="text" name="fullname" id="fullname" value="<?php echo KT_escapeAttribute($row_rsscotts_contact['fullname']); ?>" size="47" />
<?php echo $tNGs->displayFieldHint("fullname");?> <?php echo $tNGs->displayFieldError("scotts_contact", "fullname"); ?>
</td>
</tr>
<tr>
<td ><label for="phone">Phone:</label></td>
<td>
<input type="text" name="phone" id="phone" value="<?php echo KT_escapeAttribute($row_rsscotts_contact['phone']); ?>" size="47" />
<?php echo $tNGs->displayFieldHint("phone");?> <?php echo $tNGs->displayFieldError("scotts_contact", "phone"); ?>
</td>
</tr>
<tr>
<td><label for="email">Email:</label></td>
<td>
<input type="text" name="email" id="email" value="<?php echo KT_escapeAttribute($row_rsscotts_contact['email']); ?>" size="47" />
<?php //echo $tNGs->displayFieldHint("email");?> <?php echo $tNGs->displayFieldError("scotts_contact", "email"); ?>
</td>
</tr>
<tr>
<td><label for="tellus">Looking for:</label></td>
<td>
<textarea name="tellus" id="tellus" cols="37" rows="5"><?php echo KT_escapeAttribute($row_rsscotts_contact['tellus']); ?></textarea>
<?php echo $tNGs->displayFieldHint("tellus");?> <?php echo $tNGs->displayFieldError("scotts_contact", "tellus"); ?>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="KT_Insert1" id="KT_Insert1" value="Submit" class="button-blue" />
<input name="Reset" type="reset" value="Reset" class="button-grey" />
</td>
</tr>
</table>
</form>
test1.php:
test2.php (the code you’re trying to insert in):
The result:
So it is as if the code “echo ‘hello world’;” was sitting right where {FORMINSERT} was. You can just create a bunch of PHP files to include like that, and make some if statements to handle the replacements.