473,511 Members | 15,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form which updates MySQL DB, then sends email notification

2 New Member
Hello,
I have a form which allows members of my team to update a particular table, upon updating I have php set to send an email to a certain address. What I'd like to include in this email is the table after it's been updated.

Here's what I'm currently using which isn't working:
[PHP]
<?php

$to = "user@domain.com";
$from = "user@domain.com";
$subject = "subject";
//
$message =
$connection = mysql_pconnect("localhost","username","pw") or die('Could not connect: ' . mysql_error());
mysql_select_db("status1_123TStatus", $connection) or die('Could not select database' . mysql_error());

// no problems so query the db
$SQL = "SELECT * FROM tbname;";
$result = mysql_query($SQL) or die('Query failed: ' . mysql_error());
$message = "$output";
$output = "<table border=\"1\">\n" .
"<tr>\n" .
"<td>Id</td>\n" .
"<td>service</td>\n" .
"<td>CurrentStatus</td>\n" .
"</tr>\n";

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
$id = $row[0];
$service = $row[1];
$CurrentStatus = $row[2];
$output .= "\t<tr>\n" .
"\t\t<td>$id</td>\n" .
"\t\t<td>$service</td>\n" .
"\t\t<td>$CurrentStatus</td>\n" .
"\t</tr>\n";
}

$output .= "</table>\n";
mysql_free_result($result);

//

$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
$to = "$to";
mail($to, $subject, $message, $headers);

header("Refresh: 5; url=");

?>
[/PHP]

Anyone have an idea as to what I'm doing wrong here?? Please help!

Thanks!
Sep 20 '07 #1
3 2324
ronverdonk
4,258 Recognized Expert Specialist
Welcome to TSDN!

What exactly is NOT WORKING? Is it the db part, the build of the message, is it the mail() command???

Ronald
Sep 20 '07 #2
ivdezine
2 New Member
Hello, thanks for the reply!

I'm getting the email, but there is no content within the body of the email. I believe the mysql query may be incorrect for an email. Thoughts???
Sep 20 '07 #3
pbmods
5,821 Recognized Expert Expert
Heya, Ivdezine. Welcome to TSDN!

You might want to switch these two statements around:
Expand|Select|Wrap|Line Numbers
  1. $message = "$output";
  2. $output = "<table border=\"1\">\n" .
  3. "<tr>\n" .
  4. "<td>Id</td>\n" .
  5. "<td>service</td>\n" .
  6. "<td>CurrentStatus</td>\n" .
  7. "</tr>\n";
  8.  
Or better yet, since $output isn't doing anything anyway:
Expand|Select|Wrap|Line Numbers
  1. $message = "<table border=\"1\">\n" .
  2. "<tr>\n" .
  3. "<td>Id</td>\n" .
  4. "<td>service</td>\n" .
  5. "<td>CurrentStatus</td>\n" .
  6. "</tr>\n";
  7.  
Sep 20 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
1968
by: Joe | last post by:
I have wrote a script to query my mysql database based up a name that is selected from an HTML list menu, the form action calls to my php script from my html doc, I have tested connectivity to the...
3
6592
by: Armin Irger | last post by:
Hi, i'am running a debian sarge with the delivered apache2 mysql and php4. The file "mitarbeiter_eingabe.php" gets the data over a html <FORM> and send it to...
5
1758
by: elyob | last post by:
I'm just rewriting some backend management pages, in fact rewriting the whole database too. One of these pages has a simple HTML form to edit existing rows. I don't want to populate the form...
16
2858
by: Philippe C. Martin | last post by:
Hi, I am trying to change the data in a form field from python. The following code does not crash but has no effect as if "form" is just a copy of the original html form. Must I recreate the...
2
3399
by: Krzysztof Karnicki | last post by:
I would like develop Form on my Windows Application, that is going to notify the user, just like Microsoft Office 2003 shows that there are new mail coming. When I use System.Windows.Forms.Form and...
9
5800
by: Jervin Justin | last post by:
Hi, I've been having this problem for some time with Web Forms: I have a web app that sends data to a service when the user presses a button. Based on the data, the server will send several...
0
1619
by: vsrprasad16 | last post by:
Hi All, I am implementing a notification form similar to outlook email notification. my application call this notification form from a dll. this dll includes a form class and this dll has some...
39
5825
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
8
6237
by: Nick | last post by:
Hi there, I have a GridView in an UpdatePanel, each time the UpdatePanels Load event fires I set the DataSource and call DataBind of the grid view. This works great once, I add an item to the...
0
7245
marktang
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,...
0
7144
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7427
jinu1996
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...
0
7512
tracyyun
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...
1
5069
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
449
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.