RyanMinor Posted May 4, 2010 Share Posted May 4, 2010 I am trying to build a page that displays a registered user's information and emails it to me at the same time. The user's information is inserted into the database, but the confirmation page displays an http500 internal server error. I'm not sure if my syntax is incorrect or not because I have made contact forms before, but this is my first time that I am trying to pull data from a database and send it in an email. Below is my code. Please let me know what is wrong. Thanks in advance. <?php session_start(); ?> <?php require_once('../../Connections/connDB.php'); ?> <?php //mail processing script $to = 'ryanminor@hotmail.com'; $subject = 'New Travel Arrangement Registration'; $Email = $row_rsDisplay['Email_Address']; $Name = $row_rsDisplay['First_Name'] $row_rsDisplay['Middle_Name'] $row_rsDisplay['Last_Name']; $Birth = $row_rsDisplay['Date_of_Birth']; $Phone = $row_rsDisplay['Phone_Number']; $Type = $row_rsDisplay['Travel_Type']; // build the message $message = "Email Address: $Email\r\n\r\n"; $message .= "Name: $Name\r\n\r\n"; $message .= "Date of Birth: $Birth\r\n\r\n"; $message .= "Phone Number: $Phone\r\n\r\n"; $message .= "Travel Method: $Type\r\n\r\n"; $headers = "From: Travel Website <trioadmin@triogrants.com>\r\n"; $headers .= 'Content-Type: text/plain; charset=utf-8'; $headers .= "\r\nCc: rminor@cds2.com"; $headers .= "\r\nReply-To: $Email"; // send it $mailSent = mail($to, $subject, $message, $headers); 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 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"> </td> </tr> </table> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"> <td width="201"><BR> <a href="index.php">HOME</a><BR> <img src="../img/menubar.jpg" width="201" height="11" border="0" alt=""><BR> <a href="reader_resources.php">READER RESOURCES</a><BR> <img src="../img/menubar.jpg" width="201" height="11" border="0" alt=""><BR> TRAVEL REGISTRATION<BR> <img src="../img/menubar.jpg" width="201" height="11" border="0" alt=""><BR> <a href="contact_us.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 here to log in and update your information.<br> <ul> <li>First Name: <span class="style5"><?php echo $row_rsDisplay['First_Name']; ?></span><br> <br> </li> <li>Middle Name: <span class="style5"><?php echo $row_rsDisplay['Middle_Name']; ?></span><br> <br> </li> <li>Last Name: <span class="style5"><?php echo $row_rsDisplay['Last_Name']; ?></span><br> <br> </li> <li>Date of Birth: <span class="style5"><?php echo $row_rsDisplay['Date_of_Birth']; ?></span><br> <br> </li> <li>Phone Number: <span class="style5"><?php echo $row_rsDisplay['Phone_Number']; ?></span><br> <br> </li> <li>Method of Travel: <span class="style5"><?php echo $row_rsDisplay['Travel_Type']; ?></span><br> <br> </li> <li>Airport Departing From: <span class="style5"><?php echo $row_rsDisplay['Airport_Depart']; ?></span><br> <br> </li> <li>Airport Returning To: <span class="style5"><?php echo $row_rsDisplay['Airport_Return']; ?></span><br> <br> </li> <li>Train Station Departing From: <span class="style5"><?php echo $row_rsDisplay['Train_Depart']; ?></span><br> <br> </li> <li>Train Station Returning To: <span class="style5"><?php echo $row_rsDisplay['Train_Return']; ?></span><br> <br> </li> <li>Additional Comments or Accomodations: <span class="style5"><?php echo $row_rsDisplay['Additional_Comments']; ?> </span></li> </ul> </td> </tr> </table> </td> </tr> </table> </body> </html> <?php mysql_free_result($rsDisplay); ?> [/ code] Quote Link to comment Share on other sites More sharing options...
satya61229 Posted May 4, 2010 Share Posted May 4, 2010 For lots of headers and attachment I always suggest using a library written and tested for sending email. One is phpmailer. Simple mail() function is not very good to use for us. Quote Link to comment Share on other sites More sharing options...
RyanMinor Posted May 4, 2010 Author Share Posted May 4, 2010 I think I realized one of my mistakes. Normally when I make a contact form I make it so that it processes on the same page. I kind of usd that format for this, however this email is being sent using MySQL data and not form data from the $_POST variables. Therefore, would I need to declare the variables immediately after the recordset completes. If so, where would I put my mailing script? Quote Link to comment Share on other sites More sharing options...
RyanMinor Posted May 5, 2010 Author Share Posted May 5, 2010 Anybody have any suggestions? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.