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 4573 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 that it would be over my head buy the site maker,...
|
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 ASP.NET
platform and being delivered by a Debian...
|
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 as
name value pair. The our employee's then has to...
|
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 (textbox, dropdownlist,
others).
After...
|
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 Resume in Blob field(Document format). I want to...
|
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 forms - also included CSS and some javascript for...
|
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 outlook..
<form name="form1" method="post"...
|
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
basically dot.net develeoper ,but yahoowebhosting not...
|
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. All is working, but only the problem is in the...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |