473,372 Members | 853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

Troubles having PHP send database table info to an email address

Hello there,
I too am having a somewhat similar problem and would very much appreciate some assistance. Through PHP, I have already set up my Flash actionscript to pass info and variables onto a MySQL database that is functionable in retrieving user info (name, email, subject, and comments). My only problem is that I need to have the information that the user sends when the click submit to also send an email to the owner with the same info. He wants to get an individual email for each individual who inputs their info and hits submit.

I was trying to derive something from this code to get it to work, but nothing seemed to work:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.   $my_result = $_POST['myData'];
  3.  
  4. $my_result = mail( "sales@longbeachclothing.com", "LBC Site Inquiry: $clientSubject", 
  5. "From: ".$clientName . "
  6. Email: ".$clientEmail. "
  7. Subject: ".$clientSubject. "
  8. Message: ".$clientMessage, "From: $clientEmail" );
  9. ?>
  10.  
  11. Here is my current code. There are two files.
  12. The first is called insert.php
  13. <?php
  14. ini_set('display_error',1);
  15. ?>
  16. <?php
  17. $connection = mysql_pconnect("localhost","longbeach562","40403141") or die('Could not connect: ' . mysql_error());
  18. mysql_select_db("longbeach562", $connection) or die('Could not select database' . mysql_error());
  19. ?>
  20. <?php
  21. $_name = $_REQUEST['name'];
  22. $_email = $_REQUEST['email'];
  23. $_subject = $_REQUEST['subject'];
  24. $_comments = $_REQUEST['comments'];
  25.  
  26. if ($_name != '' && $_subject != '') {
  27. //if ($_name != '') {
  28.     $SQL = "INSERT INTO `userInfo` (`name`, `email`, `subject`, `comments`) VALUES ('$_name', '$_email', '$_subject','$_comments');";
  29.     mysql_query($SQL) or die('Query failed: ' . mysql_error());
  30.     echo("&success=Thank you, your info has been received.");
  31. } else {
  32.     echo("&success=Some of your info is missing!");
  33. }
  34. ?>
  35.  
  36. This second on is called select.php:
  37. <?php
  38. ini_set('display_error',1);
  39. ?>
  40. <?php
  41. $connection = mysql_pconnect("localhost","longbeach562","40403141") or die('Could not connect: ' . mysql_error());
  42. mysql_select_db("longbeach562", $connection) or die('Could not select database' . mysql_error());
  43.  
  44. // no problems so query the db
  45. $SQL = "SELECT * FROM userInfo;";
  46. $result = mysql_query($SQL) or die('Query failed: ' . mysql_error());  
  47. ?>
  48. <?php
  49. $output = "<table border=\"1\">\n" . 
  50.     "<tr>\n" .
  51.     "<td>Id</td>\n" .
  52.     "<td>Name(s)</td>\n" .
  53.     "<td>Email(s)</td>\n" .
  54.     "<td>Subject?</td>\n" .
  55.     "<td>Comments</td>\n" .
  56.     "<td>Date & Time</td>\n" .  
  57.     "</tr>\n";
  58.  
  59. while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
  60.     $id = $row[0];
  61.     $name = $row[1];
  62.     $email = $row[2];
  63.     $subject = $row[3];
  64.     $comments = $row[4];
  65.     $date = $row[5];
  66.     $output .= "\t<tr>\n" .
  67.         "\t\t<td>$id</td>\n" .
  68.         "\t\t<td>$name</td>\n" .
  69.         "\t\t<td>$email</td>\n" .
  70.         "\t\t<td>$subject</td>\n" .
  71.         "\t\t<td>$comments</td>\n" .
  72.         "\t\t<td>$date</td>\n" . 
  73.         "\t</tr>\n";
  74. }
  75.  
  76. $output .= "</table>\n";
  77. ?>
  78. <?php echo($output) ?>
  79. <?php
  80. mysql_free_result($result);
  81. ?>
  82. </body>
  83. </html>
Sep 2 '06 #1
0 2218

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

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
1
by: David Thompson | last post by:
Looking for a book to help me develop a philosophy for building databases (particularly on MySQL). And then taking them from concept to construction. Something like.... Start by asking which...
2
by: jlibster | last post by:
Hi, I wonder if someone can answer a quesiton for me: I'm modifying a database with the purpose of adding the new feature of address change history. My model would consist of a table for keeping...
6
by: DigitalRick | last post by:
I have been running CDONTS in my ASPpages to send emails to me sent from my guestbook. It had been working fine untill I upgraded to Server 2003 (I am also running Exchange 2003) all locally. I...
4
by: A Palmblad | last post by:
We're having a lot of trouble with one of our new servers. It's an AMD64 dual cpu system, running on Gentoo Linux, with kernel 2.6.7. Data is stored on a JFS partition. Before we installed the...
9
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to...
0
southoz
by: southoz | last post by:
Good ay all , I'm fairly new to access(a little over 5 weeks now). Since I'v started I have picked up a lot of useful information from forums such as this and in doing so will share that information...
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
2
by: adam87 | last post by:
Below is my code, what I have done is create a form which sends via asp, it works fine within IE but when testing it in Firefox the entire form is outside the page. Hope you can help! Adam Huxtable...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.