473,587 Members | 2,505 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.co m";
$from = "user@domain.co m";
$subject = "subject";
//
$message =
$connection = mysql_pconnect( "localhost","us ername","pw") or die('Could not connect: ' . mysql_error());
mysql_select_db ("status1_123TS tatus", $connection) or die('Could not select database' . mysql_error());

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

while ($row = mysql_fetch_arr ay($result, MYSQL_NUM)) {
$id = $row[0];
$service = $row[1];
$CurrentStatus = $row[2];
$output .= "\t<tr>\n" .
"\t\t<td>$i d</td>\n" .
"\t\t<td>$servi ce</td>\n" .
"\t\t<td>$Curre ntStatus</td>\n" .
"\t</tr>\n";
}

$output .= "</table>\n";
mysql_free_resu lt($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 2330
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
1974
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 databse and have added a manual sql query to my php script to be sure it is functioning properly, the problem is I'm not sure how to get the script...
3
6599
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 "mysql_mitarbeiter_daten_hinzufuegen.php" to write it in an mysql database. These already worked on php3 and mysql-3 and now on php4 and mysql4 it doesn't work. I can't found any...
5
1762
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 beforehand with all existing data. I just want to check which of the 20 fields have changed and update the data accordingly. Before (I wrote the script...
16
2878
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 form order to do that ? My point is for the client to be able to re-read the modified data.
2
3404
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 show it on a different then main thread on my application, this new form became focused, but I want that new form at the beginning acts like just...
9
5810
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 replies. Since there is no way for a service to post to a client, I am using a thread on the client that polls the server for updates. (Feel free to...
0
1623
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 object value to display the contents on form. i am filling the form with the object before "form.show." form has some timer to implement hide and...
39
5842
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 ISO-8859-1 -t UTF-8 mydb.sql mydb_utf8.sql mysqlCREATE DATABASE mydb_utf8 CHARACTER SET utf8 COLLATE utf8_general_ci;
8
6240
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 list and the control updates, my breakpoints get in in the UpdatePanel Load event. Only problem is on the second time, even though the code is...
0
7849
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8215
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7973
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5718
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5394
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2358
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 we have to send another system
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.