w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How do I turn a PHP variable string to output HTML?

Assuming you're using the built in mail function in PHP:

<?php
// multiple recipients
$to  = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html>
<head>
  <title>Birthday Reminders for August</title>
</head>
<body>
  <p>Here are the birthdays upcoming in August!</p>
  <table>
    <tr>
     
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
    </tr>
    <tr>
     
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
    </tr>
    <tr>
     
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
    </tr>
  </table>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";

// Mail it
mail($to, $subject, $message, $headers);
?>

This example is from: http://us2.php.net/manual/en/function.mail.php

The important part is the $headers variable.

By the way, as andrewsi mentioned - you need to escape your quotes:

$respondmessage = "Hello $fullname,
    We are confirming your Appointment today!
    Please <a href="http://yourlink.com/">click here to
confirm</a>!";




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.