After the customer fills the form on the website, the form data is sent to mysql and an email gets sent to me with the last form data that the customer submitted. But, the email "last mysql data" is not going as inline text. Please help me. Sample code is given below. - <?php
-
-
define('DB_NAME', 'XXXXXXX');
-
define('DB_USER', 'XXXXXXX');
-
define('DB_PASSWORD', 'XXXXXXX');
-
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
-
-
$data = mysql_query("SELECT * FROM demo ORDER BY ID DESC LIMIT 1")
-
or die(mysql_error());
-
Print "<table border cellpadding=3>";
-
while($info = mysql_fetch_array( $data ))
-
{
-
Print "<tr>";
-
Print "<th>ID:</th> <td>".$info['ID'] . "</td> ";
-
Print "<th>Input1:</th> <td>".$info['input1'] . "</td> ";
-
Print "<th>MAmount:</th> <td>".$info['MAmount'] . " </td></tr>";
-
}
-
Print "</table>";
-
-
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 = "gdssdh";
-
//$body = preg_replace("[\]",'',$body);
-
-
$mail->IsSMTP(); // telling the class to use SMTP
-
$mail->Host = "ssl://XXXXXXX.XXXXXXX.org"; // 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 = "ssl"; // sets the prefix to the servier
-
$mail->Host = " raunakgroup "; // sets GMAIL as the SMTP server
-
$mail->Port = 465; // set the SMTP port for the GMAIL server
-
$mail->Username = "XXXXXXX"; // GMAIL username
-
$mail->Password = "XXXXXXX"; // GMAIL password
-
-
$mail->SetFrom('XXXXXXX', 'HAL');
-
-
//$mail->AddReplyTo("XXXXXXX', 'First Last");
-
-
$mail->Subject = "XXXXXXX";
-
-
//THE PROBLEM IS HERE WHEN I WANT TO SEND THE DATA AS INLINE TEXT TO EMAIL FROM MYSQL IT IS NOT WORKING. ONLY "PRINT THE DATA" IS SENDING TO EMAIL.
-
-
$body = 'Print the data';
-
mysql_connect("localhost","XXXXXXX","XXXXXXX");
-
@mysql_select_db("XXXXXXX");
-
$query["SELECT * FROM demo ORDER BY ID DESC LIMIT 1"];
-
$result = mysql_query($query);
-
-
//while ($row = mysql_fetch_array ($result)) {
-
// $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
-
$mail->MsgHTML($body);
-
$address = "XXXXXXX";
-
$mail->AddAddress($address, "user2");
-
-
//$mail->AddAttachment("images/phpmailer.gif"); // attachment
-
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
-
-
if(!$mail->Send()) {
-
echo "Mailer Error: " . $mail->ErrorInfo;
-
} else {
-
echo "Message sent!";
-
}
-
-
?>
0 4254 Sign in to post your reply or Sign up for a free account.
Similar topics
by: jim west via SQLMonster.com |
last post by:
I have website problems with mySQL data base, I have a website and was told the only way to change my password is within my SQL data base files and...
|
by: Jonah Olsson |
last post by:
Dear All,
I'm currently developing a solution where large amounts of personalised
emails are being created (and no, this is not spam...) on the...
|
by: sam |
last post by:
Do anyone know how to apply send datagrid via email?
Any website for reference?
Please advise.
|
by: Dave S |
last post by:
I have a lot of forms on our web site that require the user to fill out
information and submit it back to us. currently the information comes back...
|
by: YMPN |
last post by:
Hi Everyone,
I'm deen from Riyadh.
Please do help me with some problem i have. I have this formview
control setup to recieved inputs from user...
|
by: sang |
last post by:
Hi
i am doing my project in Mysql and PHP. My problem is i want to send a Blob field to my email using the Php. That is i am storing Candidates...
|
by: steinwaygirl |
last post by:
Hi all,
I have been searching so hard for the answer to this, hopefully some of you all can help.
I have created an HTML file with various...
|
by: Malli mindwave |
last post by:
Hi,
I want to send form data to given email id, I'm using
mailto:ur@mail.com, but it doesn't working
it dirsctly goes to localSystem A/C i.e...
|
by: Malli mindwave |
last post by:
Hi,
We are using the yahoowebHostiing service for my company website, In
that one screen of the SendComments/FeedBack section is there, I'm...
|
by: sandipcd |
last post by:
After customer filling the form, the form data will be send to mysql, and an email will sent to me with the last form data that customer submitted....
|
by: better678 |
last post by:
Question:
Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct?
Answer:
Java is an object-oriented...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the...
| |