Jump to content

Recommended Posts

Hello,

I am working on combining my old mailing script with a tutorial i found on sending an attachment.

 

now I have run into a wall, though its probably something dumb i am forgetting. The page instantly echos my error for sendmail "Oops!  You forgot to fill out the email address! Click on the back arrow to go back"

 

<?

////   functions  ///////////////////////////////////////

function sendMail() {
  if (!isset ($_POST['to_email'])) { //Oops, forgot your email addy!
    die ("<p>Oops!  You forgot to fill out the email address! Click on the back arrow to go back</p>");
  }
  else {
    
    $from_name = stripslashes($_POST['from_name']);
    $from_email = stripslashes($_POST['from_email']);
    $to_name = stripslashes($_POST['to_name']);
    $to_email = stripslashes($_POST['to_email']);
    $firstname = stripslashes($_POST['firstname']);
    $lastname = stripslashes($_POST['lastname']);
    $phone = stripslashes($_POST['phone']);
    $fax = stripslashes($_POST['fax']);
    $address = stripslashes($_POST['address']);
    $address2 = stripslashes($_POST['address2']);
    $state = stripslashes($_POST['state']);
    $city = stripslashes($_POST['city']);
    $zip = stripslashes($_POST['zip']);
    $email = stripslashes($_POST['email']);
    $available = stripslashes($_POST['available']);
    $livein = stripslashes($_POST['livein']);
    $overnights = stripslashes($_POST['overnights']);
    $travel = stripslashes($_POST['travel']);
    $fulltime = stripslashes($_POST['fulltime']);
    $parttime = stripslashes($_POST['parttime']);
    $comment = stripslashes($_POST['comment']);
    $agreement = stripslashes($_POST['agreement']);
    $resume = $_FILES['resume']['tmp_name'];
    $resume_name = $_FILES['resume']['name'];
        if (is_uploaded_file($resume))    { //Do we have a file uploaded?
            $fp = fopen($resume, "rb"); //Open it
            $data = fread($fp, filesize($resume)); //Read it
            $data = chunk_split(base64_encode($data)); //Chunk it up and encode it as base64 so it can be emailed
                fclose($fp);
            }

//Let's start our headers
    ini_set(SMTP, "mail.thenannygroup.com");
    ini_set(smtp_port, 25);
    ini_set(sendmail_from, "web@thenannygroup.com");
    $headers = "From: $from_name<" . $_POST['from_email'] . ">\n";
    $headers .= "Reply-To: <" . $_POST['from_email'] . ">\n"; 
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"----=MIME_BOUNDRY_main_message\"\n"; 
    $headers .= "X-Sender: $from_name<" . $_POST['from_email'] . ">\n";
    $headers .= "X-Mailer: PHP4\n";
    $headers .= "X-Priority: 3\n"; //1 = Urgent, 3 = Normal
    $headers .= "Return-Path: <" . $_POST['from_email'] . ">\n"; 
    $headers .= "This is a multi-part message in MIME format.\n";
    $headers .= "------=MIME_BOUNDRY_main_message \n"; 
    $headers .= "Content-Type: multipart/alternative; boundary=\"----=MIME_BOUNDRY_message_parts\"\n";
    
    $message = "------=MIME_BOUNDRY_message_parts\n";
    $message .= "Content-Type: text/html; charset=\"iso-8859-1\"\n"; 
    $message .= "Content-Transfer-Encoding: quoted-printable\n"; 
    $message .= "\n"; 
    /* Add our message, in this case it's plain text.  You could also add HTML by changing the Content-Type to text/html */
    $message .= "TheNannyGroup.com - You have a new nanny applicant!
    
    
        Personal Information
        
        First Name = {$firstname} 
        Last Name = {$lastname}
        Phone = {$phone}
        Fax = {$fax}
        Address = {$address}
        Unit = {$address2}
        State = {$state}
        City = {$city}
        Zip = {$zip}
        Email = {$email}
        
    
        Employment Information
        
        Date Available = {$available}
        Live In = {$livein}
        Overnights = {$overnights}
        Travel = {$travel}
        Full Time = {$fulltime}
        Part Time = {$parttime}
        
        
        Other Information
        
        Comment = {$comment}\n";
    
    $message .= "\n"; 
    $message .= "------=MIME_BOUNDRY_message_parts--\n"; 
    $message .= "\n"; 
    $message .= "------=MIME_BOUNDRY_main_message\n"; 
    $message .= "Content-Type: application/octet-stream;\n\tname=\"" . $resume_name . "\"\n";
    $message .= "Content-Transfer-Encoding: base64\n";
    $message .= "Content-Disposition: attachment;\n\tfilename=\"" . $resume_name . "\"\n\n";
    $message .= $data; //The base64 encoded message
    $message .= "\n"; 
    $message .= "------=MIME_BOUNDRY_main_message--\n";
    
    //Send the message
    
mail("to_name<$to_email>", $subject, $message, $headers);
    echo "Mail Sent. Thank you for your interest.";

    //--> adding entry to the DB on successful Mail Send
    Enter_New_Entry($firstname,$lastname,$phone,$fax,$address,$address2,$state,$city,$zip,$email,$available,$livein,$overnights,$travel,$fulltime,$parttime,$comment,$agreement);
    }
}

function Enter_New_Entry 
($firstname,$lastname,$phone,$fax,$address,$address2,$state,$city,$zip,$email,$available,$livein,$overnights,$travel,$fulltime,$parttime,$comment,$agreement) {

$cnx = mysql_connect("localhost","**********","**********");
    if (!$cnx) {
        die('Could not connect: ' . mysql_error());
    }

$db_selected = mysql_select_db('*********', $cnx);
if (!$db_selected) {
    die ('Can\'t use Records Database : ' . mysql_error());
}

    $SQL_Exec_String = "Insert Into ******** (firstname, lastname, phone, fax, address, address2, state, city, zip, email, available, livein, overnights, travel, fulltime, parttime, comment, agreement)
            Values ('$firstname', '$lastname', '$phone', '$fax', '$address', '$address2', '$state', '$city', '$zip', '$email', '$available', '$livein', '$overnights', '$travel', '$fulltime', '$parttime', '$comment', '$agreement')";

    $cur = mysql_query($SQL_Exec_String);
    if (!$cur) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}

mysql_close($cnx);  
header("location: http://www.thenannygroup.com/verify.php"); 

}

////   code  ///////////////////////////////////////

sendMail();

?>

 

 

anyone see something that catches thier eye?

 

Thanks

croix

Link to comment
https://forums.phpfreaks.com/topic/75541-sendmail-with-attachment/
Share on other sites

to_email is a hidden field in my form. but i changed it anyway, to check for my agreement. In the process, i accidentaly commented out my "die" line, and the page shows up when i do that. with that line commented out, the page appears, and when i fill it out and submit, the information is stored in my database, and i am redirected to my header page, but the email never comes.

 

if the die line is left in, i just instantly get the error on screen "Oops!  You did not agree to our terms! Click on the back arrow to go back"

 

Here is the updated code:

 

<?

////   functions  ///////////////////////////////////////

function sendMail() {
  if (!isset ($_POST['agreement'])) { //Oops, you did not agree to our terms    
  die ("<p>Oops!  You did not agree to our terms! Click on the back arrow to go back</p>");
  }
  else {
    
    $from_name = stripslashes($_POST['from_name']);
    $from_email = stripslashes($_POST['from_email']);
    $to_name = stripslashes($_POST['to_name']);
    $to_email = stripslashes($_POST['to_email']);
    $firstname = stripslashes($_POST['firstname']);
    $lastname = stripslashes($_POST['lastname']);
    $phone = stripslashes($_POST['phone']);
    $fax = stripslashes($_POST['fax']);
    $address = stripslashes($_POST['address']);
    $address2 = stripslashes($_POST['address2']);
    $state = stripslashes($_POST['state']);
    $city = stripslashes($_POST['city']);
    $zip = stripslashes($_POST['zip']);
    $email = stripslashes($_POST['email']);
    $available = stripslashes($_POST['available']);
    $livein = stripslashes($_POST['livein']);
    $overnights = stripslashes($_POST['overnights']);
    $travel = stripslashes($_POST['travel']);
    $fulltime = stripslashes($_POST['fulltime']);
    $parttime = stripslashes($_POST['parttime']);
    $comment = stripslashes($_POST['comment']);
    $agreement = stripslashes($_POST['agreement']);
    $resume = $_FILES['resume']['tmp_name'];
    $resume_name = $_FILES['resume']['name'];
        if (is_uploaded_file($resume))    { //Do we have a file uploaded?
            $fp = fopen($resume, "rb"); //Open it
            $data = fread($fp, filesize($resume)); //Read it
            $data = chunk_split(base64_encode($data)); //Chunk it up and encode it as base64 so it can be emailed
                fclose($fp);
            }

//Let's start our headers
    ini_set(SMTP, "mail.thenannygroup.com");
    ini_set(smtp_port, 25);
    ini_set(sendmail_from, "web@thenannygroup.com");
    $headers = "From: $from_name<" . $_POST['from_email'] . ">\n";
    $headers .= "Reply-To: <" . $_POST['from_email'] . ">\n"; 
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"----=MIME_BOUNDRY_main_message\"\n"; 
    $headers .= "X-Sender: $from_name<" . $_POST['from_email'] . ">\n";
    $headers .= "X-Mailer: PHP4\n";
    $headers .= "X-Priority: 3\n"; //1 = Urgent, 3 = Normal
    $headers .= "Return-Path: <" . $_POST['from_email'] . ">\n"; 
    $headers .= "This is a multi-part message in MIME format.\n";
    $headers .= "------=MIME_BOUNDRY_main_message \n"; 
    $headers .= "Content-Type: multipart/alternative; boundary=\"----=MIME_BOUNDRY_message_parts\"\n";
    
    $message = "------=MIME_BOUNDRY_message_parts\n";
    $message .= "Content-Type: text/html; charset=\"iso-8859-1\"\n"; 
    $message .= "Content-Transfer-Encoding: quoted-printable\n"; 
    $message .= "\n"; 
    /* Add our message, in this case it's plain text.  You could also add HTML by changing the Content-Type to text/html */
    $message .= "TheNannyGroup.com - You have a new nanny applicant!
    
    
        Personal Information
        
        First Name = {$firstname} 
        Last Name = {$lastname}
        Phone = {$phone}
        Fax = {$fax}
        Address = {$address}
        Unit = {$address2}
        State = {$state}
        City = {$city}
        Zip = {$zip}
        Email = {$email}
        
    
        Employment Information
        
        Date Available = {$available}
        Live In = {$livein}
        Overnights = {$overnights}
        Travel = {$travel}
        Full Time = {$fulltime}
        Part Time = {$parttime}
        
        
        Other Information
        
        Comment = {$comment}\n";
    
    $message .= "\n"; 
    $message .= "------=MIME_BOUNDRY_message_parts--\n"; 
    $message .= "\n"; 
    $message .= "------=MIME_BOUNDRY_main_message\n"; 
    $message .= "Content-Type: application/octet-stream;\n\tname=\"" . $resume_name . "\"\n";
    $message .= "Content-Transfer-Encoding: base64\n";
    $message .= "Content-Disposition: attachment;\n\tfilename=\"" . $resume_name . "\"\n\n";
    $message .= $data; //The base64 encoded message
    $message .= "\n"; 
    $message .= "------=MIME_BOUNDRY_main_message--\n";
    
    //Send the message
    
mail("to_name<$to_email>", $subject, $message, $headers);
    echo "Mail Sent. Thank you for your interest.";

    //--> adding entry to the DB on successful Mail Send
    Enter_New_Entry($firstname,$lastname,$phone,$fax,$address,$address2,$state,$city,$zip,$email,$available,$livein,$overnights,$travel,$fulltime,$parttime,$comment,$agreement);
    }
}

function Enter_New_Entry 
($firstname,$lastname,$phone,$fax,$address,$address2,$state,$city,$zip,$email,$available,$livein,$overnights,$travel,$fulltime,$parttime,$comment,$agreement) {

$cnx = mysql_connect("localhost","********","********");
    if (!$cnx) {
        die('Could not connect: ' . mysql_error());
    }

$db_selected = mysql_select_db('********', $cnx);
if (!$db_selected) {
    die ('Can\'t use Records Database : ' . mysql_error());
}

    $SQL_Exec_String = "Insert Into ******** (firstname, lastname, phone, fax, address, address2, state, city, zip, email, available, livein, overnights, travel, fulltime, parttime, comment, agreement)
            Values ('$firstname', '$lastname', '$phone', '$fax', '$address', '$address2', '$state', '$city', '$zip', '$email', '$available', '$livein', '$overnights', '$travel', '$fulltime', '$parttime', '$comment', '$agreement')";

    $cur = mysql_query($SQL_Exec_String);
    if (!$cur) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}

mysql_close($cnx);  
header("location: http://www.thenannygroup.com/verify.php"); 

}

////   code  ///////////////////////////////////////

sendMail();

?>

I dont know what it is you are looking for. Everything I have is all on one page, which is the code posted above. I will include the entire page, html and all.

 

 

<?php ob_start(); ?>
<?

////   functions  ///////////////////////////////////////

function sendMail() {
  if (!isset ($_POST['agreement'])) { //Oops, you did not agree to our terms    
  die ("<p>Oops!  You did not agree to our terms! Click on the back arrow to go back</p>");
  }
  else {
    
    $from_name = stripslashes($_POST['from_name']);
    $from_email = stripslashes($_POST['from_email']);
    $to_name = stripslashes($_POST['to_name']);
    $to_email = stripslashes($_POST['to_email']);
    $firstname = stripslashes($_POST['firstname']);
    $lastname = stripslashes($_POST['lastname']);
    $phone = stripslashes($_POST['phone']);
    $fax = stripslashes($_POST['fax']);
    $address = stripslashes($_POST['address']);
    $address2 = stripslashes($_POST['address2']);
    $state = stripslashes($_POST['state']);
    $city = stripslashes($_POST['city']);
    $zip = stripslashes($_POST['zip']);
    $email = stripslashes($_POST['email']);
    $available = stripslashes($_POST['available']);
    $livein = stripslashes($_POST['livein']);
    $overnights = stripslashes($_POST['overnights']);
    $travel = stripslashes($_POST['travel']);
    $fulltime = stripslashes($_POST['fulltime']);
    $parttime = stripslashes($_POST['parttime']);
    $comment = stripslashes($_POST['comment']);
    $agreement = stripslashes($_POST['agreement']);
    $resume = $_FILES['resume']['tmp_name'];
    $resume_name = $_FILES['resume']['name'];
        if (is_uploaded_file($resume))    { //Do we have a file uploaded?
            $fp = fopen($resume, "rb"); //Open it
            $data = fread($fp, filesize($resume)); //Read it
            $data = chunk_split(base64_encode($data)); //Chunk it up and encode it as base64 so it can be emailed
                fclose($fp);
            }

//Let's start our headers
    ini_set(SMTP, "mail.thenannygroup.com");
    ini_set(smtp_port, 25);
    ini_set(sendmail_from, "web@thenannygroup.com");
    $headers = "From: $from_name<" . $_POST['from_email'] . ">\n";
    $headers .= "Reply-To: <" . $_POST['from_email'] . ">\n"; 
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"----=MIME_BOUNDRY_main_message\"\n"; 
    $headers .= "X-Sender: $from_name<" . $_POST['from_email'] . ">\n";
    $headers .= "X-Mailer: PHP4\n";
    $headers .= "X-Priority: 3\n"; //1 = Urgent, 3 = Normal
    $headers .= "Return-Path: <" . $_POST['from_email'] . ">\n"; 
    $headers .= "This is a multi-part message in MIME format.\n";
    $headers .= "------=MIME_BOUNDRY_main_message \n"; 
    $headers .= "Content-Type: multipart/alternative; boundary=\"----=MIME_BOUNDRY_message_parts\"\n";
    
    $message = "------=MIME_BOUNDRY_message_parts\n";
    $message .= "Content-Type: text/html; charset=\"iso-8859-1\"\n"; 
    $message .= "Content-Transfer-Encoding: quoted-printable\n"; 
    $message .= "\n"; 
    /* Add our message, in this case it's plain text.  You could also add HTML by changing the Content-Type to text/html */
    $message .= "TheNannyGroup.com - You have a new nanny applicant!
    
    
        Personal Information
        
        First Name = {$firstname} 
        Last Name = {$lastname}
        Phone = {$phone}
        Fax = {$fax}
        Address = {$address}
        Unit = {$address2}
        State = {$state}
        City = {$city}
        Zip = {$zip}
        Email = {$email}
        
    
        Employment Information
        
        Date Available = {$available}
        Live In = {$livein}
        Overnights = {$overnights}
        Travel = {$travel}
        Full Time = {$fulltime}
        Part Time = {$parttime}
        
        
        Other Information
        
        Comment = {$comment}\n";
    
    $message .= "\n"; 
    $message .= "------=MIME_BOUNDRY_message_parts--\n"; 
    $message .= "\n"; 
    $message .= "------=MIME_BOUNDRY_main_message\n"; 
    $message .= "Content-Type: application/octet-stream;\n\tname=\"" . $resume_name . "\"\n";
    $message .= "Content-Transfer-Encoding: base64\n";
    $message .= "Content-Disposition: attachment;\n\tfilename=\"" . $resume_name . "\"\n\n";
    $message .= $data; //The base64 encoded message
    $message .= "\n"; 
    $message .= "------=MIME_BOUNDRY_main_message--\n";
    
    //Send the message
    
mail("to_name<$to_email>", $subject, $message, $headers);
    echo "Mail Sent. Thank you for your interest.";

    //--> adding entry to the DB on successful Mail Send
    Enter_New_Entry($firstname,$lastname,$phone,$fax,$address,$address2,$state,$city,$zip,$email,$available,$livein,$overnights,$travel,$fulltime,$parttime,$comment,$agreement);
    }
}

function Enter_New_Entry 
($firstname,$lastname,$phone,$fax,$address,$address2,$state,$city,$zip,$email,$available,$livein,$overnights,$travel,$fulltime,$parttime,$comment,$agreement) {

$cnx = mysql_connect("localhost","*********","*********");
    if (!$cnx) {
        die('Could not connect: ' . mysql_error());
    }

$db_selected = mysql_select_db('*********', $cnx);
if (!$db_selected) {
    die ('Can\'t use Records Database : ' . mysql_error());
}

    $SQL_Exec_String = "Insert Into ********* (firstname, lastname, phone, fax, address, address2, state, city, zip, email, available, livein, overnights, travel, fulltime, parttime, comment, agreement)
            Values ('$firstname', '$lastname', '$phone', '$fax', '$address', '$address2', '$state', '$city', '$zip', '$email', '$available', '$livein', '$overnights', '$travel', '$fulltime', '$parttime', '$comment', '$agreement')";

    $cur = mysql_query($SQL_Exec_String);
    if (!$cur) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}

mysql_close($cnx);  
header("location: http://www.thenannygroup.com/verify.php"); 

}

////   code  ///////////////////////////////////////

sendMail();

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>Become a Nanny - Apply to be listed on The Nanny Group</title>
<meta name="description" content="Please fill out this form to be considered for a listing on TheNannyGroup.com"/>
<meta name="keywords" content="become, apply, nanny group, nanny, nurse, night nurse, babysitter, childcare, home, referral, background check, location, search, find, dallas, texas, tx"/>
<meta NAME="REVISIT-AFTER" CONTENT="14 days">
<meta name="author" content="The Nanny Group - 6046 Penrose Ave, Dallas, TX 75206">
<meta NAME="ROBOTS" CONTENT="ALL">
<meta NAME="DISTRIBUTION" CONTENT="GLOBAL">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="copyright" content="Copyright (c)2007 THE NANNY GROUP. All rights reserved." />
<link rel="stylesheet" type="text/css" href="tng_style.css" />
<style type="text/css">
<!--
body {
background-image: url(images/TileBG.jpg);
background-repeat: repeat;
}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>

<body onload="MM_preloadImages('images/tng_home_2.png','images/tng_services_2.png','images/tng_apply_2.png','images/tng_search_2.png','images/tng_contact_2.png','images/tng_testimonials_2.png','images/tng_background_2.png')">
<div id="container">
<div id="header"></div>
<div id="content">


<div id="main">
<form action="http://www.thenannygroup.com/apply_inprogress3.php" method="post">
<input name="from_name" type="hidden" id="from_name" value="The Nanny Group" />
<input name="from_email" type="hidden" id="from_email" value="web@thenannygroup.com" />
<input name="to_name" type="hidden" id="to_name" value="The Nanny Group" />
<input name="to_email" type="hidden" id="to_email" value="applicants@thenannygroup.com" />
<fieldset><legend>Contact Information</legend><br>
<table>

<tr>
	<td><p><label for="firstname">First Name</label> <input name="firstname" type="text" id="firstname" />
</p><br>
	</td>
	<td><p><label for="lastname">Last Name</label> <input name="lastname" type="text" id="lastname" />
</p><br>
	</td>
</tr>

<tr>
	<td><p><label for="phone">Phone</label> <input name="phone" type="text" id="phone" />
</p><br>
	</td>
	<td><p><label for="fax">Fax</label> <input name="fax" type="text" id="fax" value="optional"/>
</p><br>
	</td>
</tr>

<tr>
	<td><p><label for="address">Address</label> <input name="address" type="text" id="address" />
</p>
<p><label for="address2">Unit</label> <input name="address2" type="text" id="address2" value="optional"/>
</p><br>
	</td>
	<td><p><label for="state">State</label> <select name="state" id="state" />
<option>My State</option>
	  <option>Puerto Rico</option>
          <option>Alabama</option>
          <option>Alaska</option>
          <option>Arizona</option>
          <option>Arkansas</option>
          <option>California</option>
          <option>Colorado</option>
	  <option>Conneticut</option>
          <option>Delaware</option>
          <option>Florida</option>
          <option>Georgia</option>
          <option>Hawaii</option>
	  <option>Idaho</option>
          <option>Illinois</option>
          <option>Indiana</option>
	  <option>Iowa</option>
          <option>Kansas</option>
          <option>Kentucky</option>
	  <option>Louisiana</option>
          <option>Maine</option>
          <option>Maryland</option>
	  <option>Massachusetts</option>
	  <option>Michigan</option>
          <option>Minnesota</option>
          <option>Mississippi</option>
	  <option>Missouri</option>
          <option>Montana</option>
          <option>Nebraska</option>
	  <option>Nevada</option>
          <option>New Hampshire</option>
          <option>New Jersey</option>
	  <option>New Mexico</option>
          <option>New York</option>
          <option>North Carolina</option>
          <option>North Dakota</option>
          <option>Ohio</option>
	  <option>Oklahoma</option>
          <option>Oregon</option>
          <option>Pennsylvania</option>
  	  <option>Rhode Island</option>
	  <option>South Carolina</option>
          <option>South Dakota</option>
          <option>Tennessee</option>
      <option>Texas</option>
  	  <option>Utah</option>
	  <option>Vermont</option>
          <option>Virginia</option>
          <option>Washington</option>
	  <option>Washington, DC</option>
	  <option>West Virginia</option>
          <option>Wisconsin</option>
          <option>Wyoming</option>
	  <option>Other</option>
</select></p><br>
	</td>
</tr>

<tr>
	<td><p><label for="city">City</label><input name="city" type="text" id="city" />
</p>
	</td>
	<td><p><label for="zip">Zip</label><input name="zip" type="text" id="zip" size="10" />
</p>
	</td>
</tr>

</table>	<br>
<p><label for="email">Email</label><input name="email" type="text" id="email" />
</p>

</fieldset>

<fieldset>
<legend>Employment Information</legend><br>

	<p><label for="company">Date Available</label> <input name="available" type="text" id="available" />
</p><br>

	<p><label for="resume">Resume</label><input name="resume" type="file" id="resume"  />
</p><br>
<table>
<tr>
	<td><p><label for="livein">Live In</label><input name="livein" type="checkbox" id="livein" value="yes" />
	</td>
	<td><p><label for="overnights">Overnights</label><input name="overnights" type="checkbox" id="overnights" value="yes" />
	</td>
	<td><p><label for="travel">Travel</label><input name="travel" type="checkbox" id="travel" value="yes" />
	</td>
</tr>
<tr>
	<td><p><label for="fulltime">Full Time</label><input name="fulltime" type="checkbox" id="fulltime" value="yes" />
	</td>
	<td><p><label for="parttime">Part Time</label><input name="parttime" type="checkbox" id="parttime" value="yes" />
	</td>

</tr>
</table>	




</fieldset>

<fieldset><legend>Additional Information</legend><br>
<p><label for="comment"><div align="center">Questions <br>or<br> Comments</div></label><textarea name="comment" cols="50" rows="4" id="comment">optional</textarea></p><br>
<p><img src="images/spacer.gif" width="25" height="5" /><input name="agreement" type="checkbox" id="agreement" value="yes" /><img src="images/spacer.gif" width="5" height="5" />I agree to the <a href="terms.php" target="_blank">Terms of Employment</a></p>
<br>
<p class="submit"><input type="submit" value="Submit" /><p class="reset"><input type="reset" value="Reset" /></p>

</form>
</div>

<div id="navcolumn">

<a href="index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Home','','images/tng_home_2.png',1)"><img src="images/tng_home_1.png" alt="Home" name="Home" width="180" height="60" border="0" id="Home" /></a>
<a href="services.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Services','','images/tng_services_2.png',1)"><img src="images/tng_services_1.png" alt="Our Services" name="Services" width="180" height="29" border="0" id="Services" /></a>
<a href="apply.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Apply','','images/tng_apply_2.png',1)"><img src="images/tng_apply_1.png" alt="Apply to be a Nanny" name="Apply" width="180" height="30" border="0" id="Apply" /></a>
<a href="search.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Search','','images/tng_search_2.png',1)"><img src="images/tng_search_1.png" alt="Search for a Nanny" name="Search" width="180" height="33" border="0" id="Search" /></a>
<a href="contact.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Contact','','images/tng_contact_2.png',1)"><img src="images/tng_contact_1.png" alt="Contact Us" name="Contact" width="180" height="36" border="0" id="Contact" /></a>
<a href="testimonials.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Testimonials','','images/tng_testimonials_2.png',1)"><img src="images/tng_testimonials_1.png" alt="Client Testimonials" name="Testimonials" width="180" height="33" border="0" id="Testimonials" /></a>
<a href="background.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Background','','images/tng_background_2.png',1)"><img src="images/tng_background_1.png" alt="Background Check Service" name="Background" width="180" height="74" border="0" id="Background" /></a>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
</div>


</div>

<div id="footer"></div>
</div>
<div align="center">
    <h2><a href="index.php">Home</a> | <a href="services.php">Services</a> | <a href="apply.php">Apply</a> | <a href="search.php">Search</a> | <a href="contact.php">Contact Us</a> | <a href="testimonials.php">Testimonials</a> | <a href="background.php">Background Check</a> | <a href="sitemap.php">Site Map</a></h2>
</div>
</body>

</html>
<?php
    include_once 'replacePngTags.php';
    echo replacePngTags(ob_get_clean());
?>

UPDATE

 

The code is slightly different now, and now the problem i am having is a different one. Now, the page displays, and when I submit it, the information is written to the database properly. I also receive an email, but there is no text in the email, and there is a blank 0Kb mime-type file attached. Here is a screen shot of the email.

 

app_email.jpg

 

and here's the code:

 

<?

////   functions  ///////////////////////////////////////

function sendMail() {
  if (!isset ($_POST['agreement'])) { //Oops, you did not agree to our terms    
  die ("<p>Oops!  You did not agree to our terms! Click on the back arrow to go back</p>");
  }
  else {
    
    $from_name = stripslashes($_POST['from_name']);
    $from_email = stripslashes($_POST['from_email']);
    $to_name = stripslashes($_POST['to_name']);
    $to_email = stripslashes($_POST['to_email']);
    $firstname = stripslashes($_POST['firstname']);
    $lastname = stripslashes($_POST['lastname']);
    $phone = stripslashes($_POST['phone']);
    $fax = stripslashes($_POST['fax']);
    $address = stripslashes($_POST['address']);
    $address2 = stripslashes($_POST['address2']);
    $state = stripslashes($_POST['state']);
    $city = stripslashes($_POST['city']);
    $zip = stripslashes($_POST['zip']);
    $email = stripslashes($_POST['email']);
    $available = stripslashes($_POST['available']);
    $livein = stripslashes($_POST['livein']);
    $overnights = stripslashes($_POST['overnights']);
    $travel = stripslashes($_POST['travel']);
    $fulltime = stripslashes($_POST['fulltime']);
    $parttime = stripslashes($_POST['parttime']);
    $comment = stripslashes($_POST['comment']);
    $agreement = stripslashes($_POST['agreement']);
    $resume = $_FILES['resume']['tmp_name'];
    $resume_name = $_FILES['resume']['name'];
        if (is_uploaded_file($resume))    { //Do we have a file uploaded?
            $fp = fopen($resume, "rb"); //Open it
            $data = fread($fp, filesize($resume)); //Read it
            $data = chunk_split(base64_encode($data)); //Chunk it up and encode it as base64 so it can be emailed
                fclose($fp);
            }

//Let's start our headers
    /* ini_set(SMTP, "mail.thenannygroup.com");
    ini_set(smtp_port, 25);
    ini_set(sendmail_from, "web@thenannygroup.com"); */
    $headers = "From: $from_name<" . $_POST['from_email'] . ">\n";
    $headers .= "Reply-To: <" . $_POST['from_email'] . ">\n"; 
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"----=MIME_BOUNDRY_main_message\"\n"; 
    $headers .= "X-Sender: $from_name<" . $_POST['from_email'] . ">\n";
    $headers .= "X-Mailer: PHP4\n";
    $headers .= "X-Priority: 3\n"; //1 = Urgent, 3 = Normal
    $headers .= "Return-Path: <" . $_POST['from_email'] . ">\n"; 
    $headers .= "This is a multi-part message in MIME format.\n";
    $headers .= "------=MIME_BOUNDRY_main_message \n"; 
    $headers .= "Content-Type: multipart/alternative; boundary=\"----=MIME_BOUNDRY_message_parts\"\n";
    
    $message = "------=MIME_BOUNDRY_message_parts\n";
    $message .= "Content-Type: text/html; charset=\"iso-8859-1\"\n"; 
    $message .= "Content-Transfer-Encoding: quoted-printable\n"; 
    $message .= "\n"; 
    /* Add our message, in this case it's plain text.  You could also add HTML by changing the Content-Type to text/html */
    $message .= "TheNannyGroup.com - You have a new nanny applicant!
    
    
        Personal Information
        
        First Name = {$firstname} 
        Last Name = {$lastname}
        Phone = {$phone}
        Fax = {$fax}
        Address = {$address}
        Unit = {$address2}
        State = {$state}
        City = {$city}
        Zip = {$zip}
        Email = {$email}
        
    
        Employment Information
        
        Date Available = {$available}
        Live In = {$livein}
        Overnights = {$overnights}
        Travel = {$travel}
        Full Time = {$fulltime}
        Part Time = {$parttime}
        
        
        Other Information
        
        Comment = {$comment}\n";
    
    $message .= "\n"; 
    $message .= "------=MIME_BOUNDRY_message_parts--\n"; 
    $message .= "\n"; 
    $message .= "------=MIME_BOUNDRY_main_message\n"; 
    $message .= "Content-Type: application/octet-stream;\n\tname=\"" . $resume_name . "\"\n";
    $message .= "Content-Transfer-Encoding: base64\n";
    $message .= "Content-Disposition: attachment;\n\tfilename=\"" . $resume_name . "\"\n\n";
    $message .= $data; //The base64 encoded message
    $message .= "\n"; 
    $message .= "------=MIME_BOUNDRY_main_message--\n";
    
    //Send the message
    
mail("to_name<$to_email>", $subject, $message, $headers);
    echo "Mail Sent. Thank you for your interest.";

    //--> adding entry to the DB on successful Mail Send
    Enter_New_Entry($firstname,$lastname,$phone,$fax,$address,$address2,$state,$city,$zip,$email,$available,$livein,$overnights,$travel,$fulltime,$parttime,$comment,$agreement);
    }
}

function Enter_New_Entry 
($firstname,$lastname,$phone,$fax,$address,$address2,$state,$city,$zip,$email,$available,$livein,$overnights,$travel,$fulltime,$parttime,$comment,$agreement) {

$cnx = mysql_connect("localhost","*********","*********");
    if (!$cnx) {
        die('Could not connect: ' . mysql_error());
    }

$db_selected = mysql_select_db('**********', $cnx);
if (!$db_selected) {
    die ('Can\'t use Records Database : ' . mysql_error());
}

    $SQL_Exec_String = "Insert Into ********* (firstname, lastname, phone, fax, address, address2, state, city, zip, email, available, livein, overnights, travel, fulltime, parttime, comment, agreement)
            Values ('$firstname', '$lastname', '$phone', '$fax', '$address', '$address2', '$state', '$city', '$zip', '$email', '$available', '$livein', '$overnights', '$travel', '$fulltime', '$parttime', '$comment', '$agreement')";

    $cur = mysql_query($SQL_Exec_String);
    if (!$cur) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}

mysql_close($cnx);  
header("location: http://www.thenannygroup.com/verify.php"); 

}

////   code  ///////////////////////////////////////

if (!empty($_POST)) { sendMail(); }

?>

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.