I have a string of HTML that I want to dynamically replace with PHP variables from a $_POST.
Here is my string:
$message = '<html><body><font face="Arial, Helvetica" size=2><strong>Name:</strong> {$first} {$last}<br/><br/>';
Here is my PHP:
foreach ($_POST as $key=>$value) {
$$key = mysql_real_escape_string(strip_tags(ucfirst(strtolower($_POST[$key]))));
$text = str_replace('{'.$key.'}', $value, $message);
//echo $text;
}
But my str_replace is not working right. I've tried doing the string like this:
$message = '<html><body><font face="Arial, Helvetica" size=2><strong>Name:</strong> {' . $first .'} {' . $last . '}<br/><br/>';
But that doesn't work either. I've tried numerous other combinations and none of them seem to work. Some help would be appreciated. Thanks.