0

I am storing PHP variables in DB like

Dear $name,
You are now member of TL, and your address is $address, $city.

If I echo variables they are showing as it is.. The variables have values and I want to send there values into an email.. How this can be done.. ?

3
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by vibhaJ
1
<?PHP


      $link = mysql_connect ($h, $u, $p) or die ("Could not connect to database, try again later");
mysql_select_db($d,$link);
$query = "SELECT * FROM emails WHERE name = ".$_POST['name'].""; 
 $result = mysql_query($query) or die(mysql_error());


while($row = mysql_fetch_array($result, MYSQL_BOTH)){
$email = $row['email'];
$name = $row['name'];
$address = $row['address'];
$city = $row['city'];
$state = $row['state'];
}



$to      = $email;
$subject = "HELLO AND WELCOME";
$message = "hello $name , \n\n your address is $address , $city , $state";
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

?>

Edited by HITMANOF44th: n/a

0

Try this code.

$name = "vibha";	
echo str_replace('$name',$name,$description); // $description is database value
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.