468,272 Members | 2,146 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,272 developers. It's quick & easy.

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 2044

Post your reply

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

Similar topics

reply views Thread by James Hong | last post: by
1 post views Thread by David Thompson | last post: by
2 posts views Thread by jlibster | last post: by
4 posts views Thread by A Palmblad | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.