Malinda Posted June 4, 2008 Share Posted June 4, 2008 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. Link to comment https://forums.phpfreaks.com/topic/108700-having-php-send-me-an-email-to-let-me-know-data-has-been-added-to-database/ Share on other sites More sharing options...
trq Posted June 4, 2008 Share Posted June 4, 2008 Take a look at the mail() function. Link to comment https://forums.phpfreaks.com/topic/108700-having-php-send-me-an-email-to-let-me-know-data-has-been-added-to-database/#findComment-557407 Share on other sites More sharing options...
Malinda Posted June 17, 2008 Author Share Posted June 17, 2008 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. Link to comment https://forums.phpfreaks.com/topic/108700-having-php-send-me-an-email-to-let-me-know-data-has-been-added-to-database/#findComment-567246 Share on other sites More sharing options...
jesushax Posted June 17, 2008 Share Posted June 17, 2008 can you post your code, we cant tell much without it... Link to comment https://forums.phpfreaks.com/topic/108700-having-php-send-me-an-email-to-let-me-know-data-has-been-added-to-database/#findComment-567250 Share on other sites More sharing options...
Malinda Posted June 17, 2008 Author Share Posted June 17, 2008 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 Link to comment https://forums.phpfreaks.com/topic/108700-having-php-send-me-an-email-to-let-me-know-data-has-been-added-to-database/#findComment-567277 Share on other sites More sharing options...
jesushax Posted June 17, 2008 Share Posted June 17, 2008 change echo "<option value = '".$row["memID"]."'>" .$row['colName']; to echo '<option value="'. $row["memID"] .'">'. $row['colName'] .'</option>'; Link to comment https://forums.phpfreaks.com/topic/108700-having-php-send-me-an-email-to-let-me-know-data-has-been-added-to-database/#findComment-567278 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.