Jump to content

Having php send me an email to let me know data has been added to database


Malinda

Recommended Posts

I'm sure this is an easy answer, but I haven't found it yet. I have several databases with form where people hit the submit button and send their data to the database. I would like an email to be sent to me whenever anyone adds data, so I can review it. Please let me know what the code is that I need to add to get this done.

 

Thanks.

 

  • 2 weeks later...

Thanks. I did figure the mail problem out as soon as I sent the message. You know how that goes. But now I have another problem.

 

In a form, I have a drop down box that I have connected to a database that shows a list of 20 colleges. A person selects the college and fills out the rest of the form and submits it. I then have a page that shows the information that has been submitted.

 

The code on that page has the usual echo statements that will show $row['colName']; etc. Everything shows correctly except the college names. Instead of printing the college names it prints the ID number instead. If I tell it to print the ID then it prints a blank space. How is it that my colName field is being populated by the id value? And how do I fix it?

 

If I don't do the connection to the database and instead hand type the 20 colleges in the drop down box, then it prints out fine. I would prefer to have it dynamically connected to the database for when the college names change though.

 

Code for the viewRegistration.php

 

<?php

 

mysql_connect("localhost","xxxxxx","xxxxxxxxx") or die(mysql_error());

mysql_select_db("nac")or die(mysql_error());

$result = mysql_query("select * from registration ") or die(mysql_error());

 

echo "<table border='0' cellspacing='1' cellpadding='1'>";

 

while($row = mysql_fetch_array($result))

{

     

echo "<tr><td align='left'>";

echo $row['colName'];

echo "</td></tr>";

 

echo "<tr><td>";

echo $row['rep1Name'];

echo "</td><td>";

echo $row['rep1Title'];

echo "</td><td>";

echo $row['rep1Phone'];

echo "</td><td>";

echo $row['rep1Email'];

echo "</td></tr>";

 

echo "<tr><td>";

echo $row['rep2Name'];

echo "</td><td>";

echo $row['rep2Title'];

echo "</td><td>";

echo $row['rep2Phone'];

echo "</td><td>";

echo $row['rep2Email'];

echo "</td></tr>";

 

echo "<tr><td>";

echo $row['guestName'];

echo "</td><td>";

echo $row['guestTitle'];

echo "</td><td>";

echo $row['guestPhone'];

echo "</td><td>";

echo $row['guestAddress'];

echo "</td><td>";

echo $row['guestFee'];

echo "</td></tr>";

 

echo "<tr><td>";

echo $row['guest2Name'];

echo "</td><td>";

echo $row['guest2Title'];

echo "</td><td>";

echo $row['guest2Phone'];

echo "</td><td>";

echo $row['guest2Address'];

echo "</td><td>";

echo $row['guest2Fee'];

echo "</td></tr>";

 

echo "<tr><td colspan=4><hr/></td></tr>";

 

}

 

echo "</table>";

 

?>

 

Code for drop down box on RegistrationForm.php

 

<tr>

<td></td>

<td colspan="4"> College:  <select name="colName" size="1">

<?php

 

$con = mysql_connect('localhost', 'xxxxx', 'xxxxxxxxx');

if (!$con){die('Could not connect; ' . mysql_error($con));}

 

mysql_select_db('nac',$con);

 

$query = "select colName, memID from member";

$result = mysql_query($query);

 

while($row= mysql_fetch_assoc($result))

{

echo "<option value = '".$row["memID"]."'>" .$row['colName'];

}

?>

 

</select>

 

You can view this website at www.malindabruce.com/nac/RegistrationForm.php and login to view the viewRegistration.php with username Malinda password malinda

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.