0

1085c1c3bd57d0a1fb75f1b1edbbda0f

look at this image. when i send this page via email it shows the php code. it does not fetch the details from mysql and then i'm fetching the mysql records based on the particular voucher id. how to send mysql fetch records page via email?

2
Contributors
6
Replies
20
Views
3 Years
Discussion Span
Last Post by Tpojka
0
require_once('phpmailer/class.phpmailer.php');
include("phpmailer/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail             = new PHPMailer();

$body             = file_get_contents('print.php');
$body             = preg_replace('/\/b]/','',$body);


$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "smtp.gmail.com"; // SMTP server
$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "tls";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 587;                   // set the SMTP port for the GMAIL server
$mail->Username   = "myemail@rediff.com";  // Email username
$mail->Password   = "mypassword";            // Email password

$mail->SetFrom('myemail@rediff.com', 'Subject 1');

$mail->AddReplyTo("myemail@rediff.com","Subject 2");

$mail->Subject = "sub";

$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$email = $_POST['email'];
$mail->AddAddress($email);

if(!$mail->Send()) {
  echo "<div align=center style=\"color:#FF0000; font-family: 'Times New Roman', Times, serif; font-size: 26px;\">Could not send email to : . $mail->ErrorInfo</div>";
} else {
  echo "<script> alert('Mail successfully sent to $email') </script>";
  echo '<META HTTP-EQUIV="Refresh" Content="0; URL=index.php">';
  exit;
}

i want to fetch mysql records here based on the particular voucher id. if user clicks the voucher id 10, it will show the full details of voucher id 10. and then i want to send that page via email. now i received an email. but i didn't get the mysql records of that particular id. how to do that?

Edited by Indians

0

I am not sure if understood well, but shouldn't called file be something like
$body = file_get_contents('print.php?id=10');
or some dynamic variable instead 10 that will be set via GET or POST input?

0

@ Tpojka : do you have any idea about that? $body = file_get_contents('print.php?id=10');

0

You need to create valid pages that refers to correspondent view (print.php).

if (isset($_GET['id']) && (int)$_GET['id'])
{
    //view with detail from DB table
}
    else
    {
        //default view
    }

Do you have that?

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.