close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

I need to send an email after an insert record

Thread began 5/04/2010 5:31 pm by bruce379400795 | Last modified 5/05/2010 4:40 pm by bruce379400795 | 1045 views | 2 replies |

bruce379400795

I need to send an email after an insert record

I have a page that users register on. They are taken immediately to a page that display's their information that they just entered (the seond page pulls their information from a query with a session variable as the filter. My question is how do I send the admin an email that contains all of the user's information? I've tried adapting my mail scripts that I have used to make contact forms, but none seem to work. My guess is that I have things placed wrong. Below is the page:

<?php session_start(); ?>
<?php require_once('../../Connections/connDB.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$colname_rsDisplay = "-1";
if (isset($_SESSION['Username'])) {
$colname_rsDisplay = (get_magic_quotes_gpc()) ? $_SESSION['Username'] : addslashes($_SESSION['Username']);
}
mysql_select_db($database_connDB, $connDB);
$query_rsDisplay = sprintf("SELECT ID, Email_Address, First_Name, Middle_Name, Last_Name, Date_of_Birth, Phone_Number, Travel_Type, Airport_Depart, Airport_Return, Train_Depart, Train_Return, Additional_Comments FROM Travel WHERE Email_Address = %s", GetSQLValueString($colname_rsDisplay, "text"));
$rsDisplay = mysql_query($query_rsDisplay, $connDB) or die(mysql_error());
$row_rsDisplay = mysql_fetch_assoc($rsDisplay);
$totalRows_rsDisplay = mysql_num_rows($rsDisplay);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>TRIO Student Support Services</title>
<link rel=stylesheet type="text/css" href="../style.css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 11pt;
}
.style3 {
font-size: 22pt;
font-weight: bold;
}
.style4 {
font-size: 12pt;
font-weight: bold;
}
.style5 {color: #FF0000}
</style>
</head>
<body bottommargin="0" leftmargin="0" rightmargin="0" topmargin="0" background="../img/background.jpg">
<table height="123" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td><img src="../img/blanklogo.jpg" width="574" height="123" border="0" alt=""></td>
<td width="100%" valign="middle" background="../img/topbg.jpg"><span class="style3">Student Support Services</span><br>
<span class="style4">Office of Federal TRIO Programs</span></td>
</tr>
</table>
<table height="40" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="100%" background="../img/topbar.jpg">&nbsp;</td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="201"><BR>
&nbsp;&nbsp;&nbsp;<a href="../index.php">HOME</a><BR>
<img src="../img/menubar.jpg" width="201" height="11" border="0" alt=""><BR>
&nbsp;&nbsp;&nbsp;<a href="../readerresources.php">READER RESOURCES</a><BR>
<img src="../img/menubar.jpg" width="201" height="11" border="0" alt=""><BR>
&nbsp;&nbsp;&nbsp;TRAVEL REGISTRATION<BR>
<img src="../img/menubar.jpg" width="201" height="11" border="0" alt=""><BR>
&nbsp;&nbsp;&nbsp;<a href="../contactus.php">CONTACT US</a><BR>
<img src="../img/menubar.jpg" width="201" height="11" border="0" alt=""><BR>
</td>
<td width="100%">
<table width="90%" border="0" align="center" cellpadding="10" cellspacing="0">
<tr valign="top">
<td>
<br>
Thank you for registering your travel information. Our travel agent will be in touch with you shortly. The information
you submitted is displayed below. Please verify it. Should you need to make any changes, please click <a href="login.php">here</a> to log in
and update your information.<br>
<br>
<table width="90%" border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<td width="44%"><div align="right">First Name:</div></td>
<td width="56%"><span class="style5"><?php echo $row_rsDisplay['First_Name']; ?></span></td>
</tr>
<tr>
<td><div align="right">Middle Name:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Middle_Name']; ?></span></td>
</tr>
<tr>
<td><div align="right">Last Name:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Last_Name']; ?></span></td>
</tr>
<tr>
<td><div align="right">Date of Birth:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Date_of_Birth']; ?></span></td>
</tr>
<tr>
<td><div align="right">Phone Number:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Phone_Number']; ?></span></td>
</tr>
<tr>
<td><div align="right">Method of Travel:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Travel_Type']; ?></span></td>
</tr>
<?php if ($row_rsDisplay['Travel_Type'] == "Flying") { ?>
<?php echo
"<tr>
<td><div align="right">Airport Departing From:</div></td>
<td><span class="style5">echo $row_rsDisplay['Airport_Depart'];</span></td>
</tr>
<tr>
<td><div align="right">Airport Returning To:</div></td>
<td><span class="style5">echo $row_rsDisplay['Airport_Return'];</span></td>
</tr>"; ?>
<?php } ?>
<tr>
<td><div align="right">Train Station Departing From:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Train_Depart']; ?></span></td>
</tr>
<tr>
<td><div align="right">Train Station Returning To:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Train_Return']; ?></span></td>
</tr>
<tr>
<td><div align="right">Additional Comments or Accomodations:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Additional_Comments']; ?></span></td>
</tr>
</table>
<br>
<br>
<br>
<br></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($rsDisplay);
?>



Please help me out. Thanks in advance!

Sign in to reply to this post

Eric Mittman

I think it would be best to send the email immediately after inserting the new user into the db. If you have it on the profile page it will send the email to the admin whenever the user visits this page.

If you have it on the insert page you can add in your script or use Universal Email and just send the email with all of the details that the user entered into the form. You would then redirect the user after the email is sent rather than after the insert.

Sign in to reply to this post

bruce379400795

I agree. I coded it like this:

if ($Result1) {
email script...
} else {
failure message...
}

Thanks for the input

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...