title: How to send mysql data to email after submitting the form by customer?
body: <p>After customer filling the form, the form data will be send to mysql, and an email will sent to me with only the last form data that customer submitted. All is working, but only <strong>the problem is in the email "mysql data" is not going as inline text</strong>. So, how to do this? I am doing in PHP. I have just two weeks experience on PHP. Sample code is given below. Please help.</p>
  
  <pre><code>&lt;?php
  
  
  define('DB_NAME', 'sandi565_form11');
  define('DB_USER', '********');
  define('DB_PASSWORD', '********');
  define('DB_HOST', 'localhost');
  
  $link = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD);
  
  if (!$link) {
      die('Could not connect: ' . mysql_error());
  }
  
  $db_selected = mysql_select_db(DB_NAME, $link);
  
  if (!$db_selected) {
      die('Can\'t use ' . DB_NAME . ': ' . mysql_error());
  }
  
  //Start Posting the data in Mysql database from Form Input
  
  $value = $_POST['input1'];
  $value2 = $_POST['MAmount'];
  
  $sql = "INSERT INTO demo (input1, MAmount) VALUES ('$value', '$value2')";
  
  if (!mysql_query($sql)) {
      die('Error: ' . mysql_error());
  
  }
  
  //start print the database on form processing page
  
  $data = mysql_query("SELECT * FROM demo ORDER BY ID DESC LIMIT 1")
   or die(mysql_error()); 
   Print "&lt;table border cellpadding=3&gt;"; 
   while($info = mysql_fetch_array( $data )) 
   { 
   Print "&lt;tr&gt;"; 
   Print "&lt;th&gt;ID:&lt;/th&gt; &lt;td&gt;".$info['ID'] . "&lt;/td&gt; "; 
   Print "&lt;th&gt;Input1:&lt;/th&gt; &lt;td&gt;".$info['input1'] . "&lt;/td&gt; "; 
   Print "&lt;th&gt;MAmount:&lt;/th&gt; &lt;td&gt;".$info['MAmount'] . " &lt;/td&gt;&lt;/tr&gt;"; 
   } 
   Print "&lt;/table&gt;"; 
  
  mysql_close();
  
  
  //end print the database on form processing page
  
  //start emailing the data
  
  
  date_default_timezone_set('Asia/Kolkata');
  
  require_once('class.phpmailer.php');
  //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
  
  $mail             = new PHPMailer();
  
  //$body             = preg_replace("[\]",'',$body);
  
  $mail-&gt;IsSMTP(); // telling the class to use SMTP
  $mail-&gt;Host       = "ssl://stevie.********.org"; // SMTP server
  $mail-&gt;SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
                                             // 1 = errors and messages
                                             // 2 = messages only
  $mail-&gt;SMTPAuth   = true;                  // enable SMTP authentication
  $mail-&gt;SMTPSecure = "ssl";                 // sets the prefix to the servier
  $mail-&gt;Host       = "stevie.********.org";      // sets GMAIL as the SMTP server
  $mail-&gt;Port       = 465;                   // set the SMTP port for the GMAIL server
  $mail-&gt;Username   = "contact@********.com";  // GMAIL username
  $mail-&gt;Password   = "********";            // GMAIL password
  
  $mail-&gt;SetFrom('contact@********.com', 'HAL');
  
  //$mail-&gt;AddReplyTo("user2@gmail.com', 'First Last");
  
  $mail-&gt;Subject    = "Halmira 469";
  //$body             = "gdssdh";
  
  //THE PROBLEM IS HERE WHEN I WANT TO SEND THE DATA AS BODY TO EMAIL FROM MYSQL IT IS NOT WORKING. SHOWING ERROR MESSAGE BODY EMPTY.
  
  $Body = "Print the data"; @MYSQL_CONNECT("localhost","********","********");
  @mysql_select_db("sandi565_form11");
  $query["SELECT * FROM demo ORDER BY ID DESC LIMIT 1"];
  $result = @MYSQL_QUERY($query);
  
  
  //$mail-&gt;AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
  
  $mail-&gt;MsgHTML($body);
  
  $address = "********@gmail.com";
  $mail-&gt;AddAddress($address, "user2");
  
  //$mail-&gt;AddAttachment("images/phpmailer.gif");      // attachment
  //$mail-&gt;AddAttachment("images/phpmailer_mini.gif"); // attachment
  
  if(!$mail-&gt;Send()) {
    echo "Mailer Error: " . $mail-&gt;ErrorInfo;
  } else {
    echo "Message sent!";
  }
  //end email the data
  
  ?&gt;
  </code></pre>